Translate-i18n-json is a node.js script that helps quickly generate i18next translations using google translate.
-
Clone this repository.
git clone git@github.com:FlorSanders/translate-i18n-json.git
-
Add
json
file with base translations intranslations
folder. -
Update index.js to point to the correct source file and language.
// Source translation file const sourceTranslation = { file: "./translations/en.json", // Source file path language: "en", // Source file language };
Note: A list of all supported languages is included in languages.js.
-
(Optional) Add
json
files with old target translations in thetranslations_old
folder. Note: The script will use the existing old translations if available, thus saving bandwidth. -
Update index.js to point to the correct target files and languages.
// Target translation files const targetTranslations = [ { file: "./translations/nl.json", // Target file path language: "nl", // Target file language oldFile: "./translations_old/nl.json", // (Optional) Old target file (overwrites auto-generated translations) }, { file: "./translations/fr.json", // Target file path language: "fr", // Target file language oldFile: "./translations_old/fr.json", // (Optional) Old target file (overwrites auto-generated translations) }, ];
-
Run the script.
npm start
- @vitalets/google-translate-api: A free and unlimited API for Google Translate for Node.js.