@asoumagne/json-translate v1.0.0
json-translate
A command-line tool to translate JSON files using DeepL API.
Installation
npm install -g json-translateUsage
json-translate [-k <key>] [-s <source>] [-t <target>] [--version]Options:
-k, --key <key>: DeepL API key-s, --source <source>: Source language (default: en)-t, --target <target>: Target language (default: fr)--version: Show version number
If the API key is provided, the tool will create a configuration file in the user's home directory (~/.json-translate). The tool will then load the source and target JSON files (<source>.json and <target>.json) and add missing translations to the target file using the DeepL API.
The tool will recursively traverse the source JSON file and add missing translations to the target JSON file. If a translation already exists in the target JSON file, the tool will skip it.
Example
Suppose you have the following en.json file:
{
"greeting": "Hello, world!",
"messages": {
"welcome": "Welcome to json-translate!",
"goodbye": "Goodbye!"
}
}And the following fr.json file:
{
"greeting": "Bonjour, le monde!",
"messages": {
"welcome": "Bienvenue à json-translate!"
}
}You can run the following command to add the missing translations to fr.json:
json-translate -k <api_key> -s en -t frThe resulting fr.json file will be:
{
"greeting": "Bonjour, le monde!",
"messages": {
"welcome": "Bienvenue à json-translate!",
"goodbye": "Au revoir!"
}
}License
This tool is licensed under the MIT License.
3 years ago