Automate locale translations in i18n
format for your Github Project, inside the Pull Requests, using OpenAI.
Features:
- Generates any missing text from Sorce to Target locale files.
- Removes obsolete text in Target locale files when removed in Source.
💡 When you change a text that already exists in target locale files, those are intentionally not translated. In case you wish to apply those translations, please manually remove the corresponding texts from target locale files.
This repository contains workflow file and script that can be imported into your own repository to get the AI Translation Workflow working. Please follow the instructions below to get your translation API and repository ready.
- Clone this repository and copy the
.github
folder into your project. - Generate an secret key in OpenAI Dashboard.
- Add secret key to your github repository:
- On GitHub, navigate to the main page of the repository.
- Select "Settings" tab.
- Expand "Secrets and variables" in sidebar and select "Actions".
- Click "New repository secret" button
- Add
OPENAI_SECRET_KEY
in "Name" field. - Paste the secret key in "Secret" field.
- Click "Add secret" to save.
- Give permissions to
github-actions[bot]
to write in your repository.- On GitHub, navigate to the main page of the repository.
- Select "Settings" tab.
- In the left sidebar, click "Actions", then click "General".
- Under "Workflow permissions", choose "Read and write permissions" and hit "Save".
- Add your source translation json file into a locales folder. E.g.
locales/en.json
- Update
.github/workflows/translate.yml
file with your settings:- In
SOURCE_LANG
, add your source language locale that represents the translation file above. - In
TARGET_LANGS
, add aCSV
list of the target locales of the languages you wish to generate translations. - If your
locales
folder is not placed in the root of your repository, updateLOCALES_ROOT_PATH
that represents where this folder is locales. E.g. If your locale files are in web/src/locales/en.json, writeweb/src
.
- In
This repository was created by Henrique Ferreira under MIT license.