1.0.10 • Published 8 months ago

i18n-translate-sync v1.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

i18n-translate-sync

Description

i18n-translate-sync is a command-line tool that helps you manage and synchronize internationalization (i18n) JSON files by automatically translating missing keys and values using the DeepL API. This tool compares your source i18n JSON file with the target i18n JSON files and fills in the gaps with translated content, ensuring that all your language files are consistent and up-to-date.

A valid DeepL API key is required to use this tool.

Getting Started

Installation

Install the package in your project directory:

npm install i18n-translate-sync

Configuration

To start the default configuration walkthrough, run:

i18n-translate-sync --configure

This command will guide you through setting up your configuration and save the settings for future use.

Running the Tool

Once configured, you can run the tool with the default settings by simply executing:

i18n-translate-sync

Alternative Configuration

If you prefer not to save the configuration, or if you want to configure the tool for a single run, you can use the --walkthrough option:

i18n-translate-sync --walkthrough

This will prompt you for all necessary inputs for the current session without affecting the saved configuration.

Here's the updated section reflecting the need for specific language codes:


Command-Line Options

You can override the default configuration by providing options directly in the command line:

i18n-translate-sync [options]

Here are the available options:

OptionDescriptionDefault Value
-k, --apiKey <key>DeepL API key. Required for translation.DEEPL_API_KEY (from config)
-sL, --sourceLang <lang>Source language code (e.g., en-GB, fr). Note that some languages require specific regional codes.SOURCE_LANG (from config)
-sP, --sourcePath <path>Path to the source i18n JSON file.SOURCE_PATH (from config)
-tL, --targetLang <langs...>Target language codes (space-separated, e.g., de, fr, es). Some languages, like en, require specific regional codes such as en-GB.TARGETS (from config)
-tP, --targetPath <paths...>Paths to the target i18n JSON files (space-separated). Corresponds to the target languages.TARGETS (from config)
-y, --yesProceed without confirmation (useful for automated scripts).AUTO_CONFIRM (from config)
-t, --testTest mode (fills JSON with "test" values instead of actual translations).TEST_MODE (from config)
--walkthroughRun the configuration walkthrough for the current session without saving the configuration.
--configureSet and save default configuration via a walkthrough.

If any required option is missing or set incorrectly, the tool will throw an error and provide guidance on how to resolve the issue.

Example Usage

To translate missing keys in your en.json source file to de.json and fr.json target files using a specific DeepL API key:

i18n-translate-sync -k your-deepl-api-key -sL en -sP ./i18n/en.json -tL de fr -tP ./i18n/de.json ./i18n/fr.json

Notes

  • This tool is ideal for managing large translation projects where consistency across multiple language files is crucial.
  • Make sure your JSON files are valid and well-structured to avoid any issues during translation.
  • The test mode (--test) is particularly useful for setting up or testing your i18n structure before committing to the full translation.
1.0.10

8 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago