@asoumagne/json-translate

1.0.0 • Public • Published

json-translate

A command-line tool to translate JSON files using DeepL API.

Installation

npm install -g json-translate

Usage

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 fr

The 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.

Readme

Keywords

Package Sidebar

Install

npm i @asoumagne/json-translate

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

5.33 kB

Total Files

5

Last publish

Collaborators

  • alain21218