
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
i18n-auto-translation
Advanced tools
Description • Usage • Demo • Known issue • Translate Providers • Credits • License
i18n-auto-translation helps you translate your i18n JSON files. You need to pick one of the translation API providers that are supported, pass the subscription key, language to which you want to translate, path to the file or directory, and you are good to go.
override
flag.{{}}
, {}
, <>
, </>
won't be translated. e.g. {{skip}} {skip} <strong> </strong> <br />
.$ npx i18n-auto-translation -k SUBSCRIPTION_KEY -d PROJECT_DIR -t DESIRED_LANGUAGE
Key | Alias | Description | Default |
---|---|---|---|
--help | / | All available options. | / |
--version | / | Current version. | / |
--apiProvider | -a | API Provider. | google-official |
--key [required] | -k | Subscription key for the API provider. | / |
--region | -r | Key region. Used only by the Official Azure API. | global |
--filePath [filePath or dirPath required] | -p | Path to a single JSON file. | / |
--dirPath [filePath or dirPath required] | -d | Path to a directory in which you will recursively find all JSON files named [from].json (e.g. en.json) | / |
--from | -f | From which language you want to translate. | en |
--to [required] | -t | To which language you want to translate. | / |
--override | -o | Override existing translation(s). | false |
--certificatePath | -c | Path to a custom certificate. | / |
--spaces | -s | Number of spaces to use when generating output JSON files. | 2 |
--maxLinesPerRequest | -l | Maximum number of lines per request. For every x number of lines, separated request is sent to the api. | 50 |
--context | -x | Context for the translation. Used only by the DeepL API. | / |
--formality | -m | Formality for the translation. Used only by the DeepL API. | default |
--trim | -i | Trim string after translation. | true |
--delay | -e | Delay between every request made to the translate api. | 250 |
--saveTo | -v | Override where translated file should be saved. (use only with --filePath option) | / |
--glossary | -g | Specify the glossary to use for the translation. Used only by the DeepL API. | / |
In some cases, you might face problem with google translate api. When you try to translate a lot of text, the response might be wrong, and it will change the structure of the translated json file.
Two issues were opened related to this problem, you can read more about it here. #12 #46
If you face this problem, try to change maxLinesPerRequest
. The default value is 50
, and that means if your file is larger than 50 lines, multiple request will be sent to the api. For every 50 lines, one request will be sent. Try to reduce this number in order to fix the issue.
In my testing, only google had this problem, but you can try the same approach if it happens with other provides. Feel free to open the issue if you have any problems.
Provider | CLI usage |
---|---|
Google Translate Official | google-official |
Azure Translator Official | azure-official |
Azure Translator RapidAPI | azure-rapid |
Deep Translate RapidAPI | deep-rapid |
Lecto Translation RapidAPI | lecto-rapid |
Lingvanex Translate RapidAPI | lingvanex-rapid |
NLP Translation RapidAPI | nlp-rapid |
Deepl | deepl-pro / deepl-free |
You don't like supported API providers? You can easily add yours. Go to src/translate/providers, create class for your provider, extend 'Translate' class, and implement 'callTranslateAPI' method. You can check in other providers for examples on how to implement this method. After you added your provider, you just need to register it in 'translate-supplier.ts' and in 'cli.ts' and you are good to go.
This software uses the following open source packages:
FAQs
Auto translate i18n JSON file(s) to desired language(s).
The npm package i18n-auto-translation receives a total of 2,916 weekly downloads. As such, i18n-auto-translation popularity was classified as popular.
We found that i18n-auto-translation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.