- ⭐ easy to integrate
- 💥 translates i18n files with one command
- 👐 supports multiples providers
add in your package.json
"@moonshot-partners/i18n-fast-translate": "moonshot-partners/i18n-fast-translate"
you have to create a configuration file in the root of your project
touch .fast-translate.json
{
"base": "translations/en-us.json", // translation base
"format": "json", // we only support json and yaml
"onlyMissingKeys": true, // translate only if the target doesn't have the key from the i18n base
"provider": "google" // translation service
"translates": [ // target files: target = file path, to: translate language
{ "target": "translations/es.json", "to": "es" },
{ "target": "translations/pt-br.json", "to": "pt" }
]
then you can run fast-translate
and it translates all the files automatically
fast-translate
to default we use google cloud to translates the files, in order to it works fine you have to set up this env
Env:
export GOOGLE_APPLICATION_CREDENTIALS="your key path"
you can find more information about this here
Config key
{ "provider": "google" }
if you are using the old API you can use this provider Env:
export GOOGLE_TRANSLATE_V2_API_KEY="YOUR API KEY"
Config key
{ "provider": "google-v2" }
.fast-translation.json
{
"base": "translations/en-us.json", // translation base
"format": "json", // we only support json and yaml
"onlyMissingKeys": true, // translate only if the target doesn't have the key from the i18n base
"commit": true, // send a git commit when it finishes to translates the files
"provider": "google" // translation service
"translates": [ // target files: target = file path, to: translate language
{ "target": "translations/es.json", "to": "es" },
{ "target": "translations/pt-br.json", "to": "pt" }
]