npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

i18n-translate-sync

v1.0.5

Published

asdf

Downloads

191

Readme

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:

| Option | Description | Default 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, --yes | Proceed without confirmation (useful for automated scripts). | AUTO_CONFIRM (from config) | | -t, --test | Test mode (fills JSON with "test" values instead of actual translations). | TEST_MODE (from config) | | --walkthrough | Run the configuration walkthrough for the current session without saving the configuration. | | | --configure | Set 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.