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

@bestcodetools/translation-cli

v1.1.2

Published

A CLI tool for managing translation files in JSON format.

Downloads

11

Readme

@bestcodetools/translation-cli

A CLI tool for managing translation files in JSON format.

Installation

To install the translation-cli globally, run the following command:

npm install -g @bestcodetools/translation-cli

If you're developing the project locally, you can link it with the following steps:

  1. Open the project folder in the shell/command prompt
  2. Run the following command:
npm link

Usage

To use the translation-cli, open your shell/command prompt and run the following command:

Set Translation

@bestcodetools/translation-cli set filename.json your.key.goes.here "your translation"

Get Translation

@bestcodetools/translation-cli get filename.json your.key.goes.here

Find Keys

@bestcodetools/translation-cli findKeys filename.json "search term" [options]

This command searches for keys that match the provided "search term" in the specified JSON file.

If filename is '*', it searches in all files within the locale directory.

  • Options:
    • --set-command: Generates a set command for each found key.
    • --set-command-all: Generates set commands for each found key in all files within the locale directory.
    • --with-values: Includes key-value pairs in the output.

For example, to generate set commands for each found key:

@bestcodetools/translation-cli findKeys filename.json "search term" --set-command

To generate set commands for each found key in all files within the locale directory:

@bestcodetools/translation-cli findKeys filename.json "search term" --set-command-all

To include key-value pairs in the output:

@bestcodetools/translation-cli findKeys filename.json "search term" --with-values

These options provide flexibility in how you interact with the keys found during the search process.

You can also use various aliases instead of @bestcodetools/translation-cli for convenience:

  • jt: short for json-translation
  • tj: short for translate-json
  • ntc: short for node-translation-cli

NOTE: The set and get commands have corresponding direct commands, such as set-translation and get-translation.

Direct commands usage

  • set-translation usage example:
set-translation filename.json your.key.goes.here "your translation"
  • get-translation usage example:
get-translation filename.json your.key.goes.here

Configuration file

The translation-cli supports a configuration file for setting default options. By default, the CLI looks for a configuration file named .translation-cli.config.json in the current directory. You can specify a different configuration file using the --config-file option.

The configuration file should be in JSON format and may include the following options:

{
  "extension": ".json",
  "localeDir": "."
}
  • extension: The file extension for the translation files.
  • localeDir: The directory where the translation files are located.

Additionally, you can use the init command to initialize a default configuration file with custom options. For example:

@bestcodetools/translation-cli init --locale-dir=my/translations/directory --extension=.txt

This command initializes a default configuration file named .translation-cli.config.json with the specified localeDir and extension options. If no options are provided, the command will use the default values.

Please note that the configuration file is used to set default options and can be useful for streamlining your workflow when using the translation-cli.

NOTE: if you use --config-file= option this file will be generated instead.