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

i18nexus-cli

v3.5.0

Published

Command line interface (CLI) for accessing the i18nexus API

Downloads

33,156

Readme

i18nexus-cli

A command line interface for accessing and managing translations through the i18nexus API

New to i18nexus?

i18nexus is a translation management web application designed for use with i18next, next-intl, and react-intl. Learn more with these quick tutorials:

Who is this CLI meant for?

  • Developers who prefer to download and bundle their translation files with their app (especially useful for those who use SSR/SSG frameworks such as Next.js).
  • Developers who wish to add, edit, or delete strings in their i18nexus project from the command line.

Installation

npm install -g i18nexus-cli

Environment Variables

The commands below have options that can be set with environment variables. Since the majority of our users are using this package in the context of their web application, this package will load the .env file in the current working directory to check for i18nexus variables. If you would prefer not to load your .env file, you can run export I18NEXUS_NO_DOT_ENV=true.

Downloading your translations

i18nexus pull -k <PROJECT_API_KEY>

The above snippet will download all of your latest translations to your current directory. Your translation files will be downloaded in a file structure based on the convention of your i18n library.

Default download path:

If your i18nexus project is set to i18next:

.
└── public
    └── locales
        ├── en
        |   └── common.json
        └── de
            └── common.json

If your i18nexus project is set to i18next and the CLI detects you're using Next.js + App Router:

.
└── locales
    ├── en
    |   └── common.json
    └── de
        └── common.json

If your i18nexus project is set to next-intl:

.
└── messages
    └── en.json
    └── de.json

If your i18nexus project is set to react-intl:

.
└── messages
    └── locales
        ├── en
        |   └── common.json
        └── de
            └── common.json

If you wish to download your files to a different directory, you can use the --path option to specify your download destination. See all options below:

Options

| Option | Default value | | ------------------- | ------------- | | --api-key or -k | | | --path or -p | (See above) | | --ver or -v | latest | | --confirmed | false | | --clean | false |

Notes

--api-key Your project API key (Can also be set using environment variable I18NEXUS_API_KEY)

--path The path to the destination folder in which translation files will be downloaded

--ver The version of your project's translations to be downloaded (Can also be set using environment variable I18NEXUS_VERSION)

--confirmed Downloads only translations that have been confirmed in i18nexus

--clean Before download, clears your destination folder specified in --path. As a safety precaution, this only deletes folders with names that match a simple language code regex. You should still ensure you are not storing any files in your destination folder that you do not want deleted.

Personal Access Tokens

The following commands require a Personal Access Token (PAT) because they write data to your i18nexus project. PATs are created in your i18nexus account dashboard.

REMEMBER: Keep these tokens a secret and do NOT publish them to any public code repositories such as Github. They should never be client facing. Treat each token as if it is your i18nexus password.

Adding new strings

i18nexus add-string or i18nexus a

i18nexus a -K 'welcome_msg' -v 'Welcome to my app!' -ns 'common' -k <PROJECT_API_KEY> -t <YOUR_PERSONAL_ACCESS_TOKEN>

The above snippet will create a new string in your i18nexus project in your common namespace.

Translations for the string will be automatically generated and machine translated for all of your project's languages, just as if you added the string manually in the i18nexus web application.

Options

| Option | Required? | | ---------------------------- | --------- | | --api-key or -k | ✔ | | --pat or -t | ✔ | | --namespace or -ns | ✔ | | --key or -K | ✔ | | --value or -v | ✔ | | --details or -d | | | --ai-instructions or -ai | |

Notes

--api-key Your project API key (Can also be set using environment variable I18NEXUS_API_KEY)

--pat A personal access token that you have generated in your i18nexus account (Can also be set using environment variable I18NEXUS_PERSONAL_ACCESS_TOKEN)

--namespace The namespace in which to create the string

--key The key of the string to create

--value The value of the string to create

--details The details of the string to create (optional)

--ai-instructions Instructions or context for AI machine translator (optional)

Updating existing strings

i18nexus update-string <namespace> <key> or i18nexus u <namespace> <key>

i18nexus u common welcome_msg -v 'Welcome' -k <PROJECT_API_KEY> -t <YOUR_PERSONAL_ACCESS_TOKEN>

The above snippet will update a the value of the string with key welcome_msg in your common namespace to Welcome.

The first 2 arguments are the namespace and the key of the string you wish to update.

You can then update the key, value, details, and/or namespace by using the command options:

Options

| Option | Required? | | ---------------------------- | --------- | | --api-key or -k | ✔ | | --pat or -t | ✔ | | --namespace or -ns | | | --key or -K | | | --value or -v | | | --details or -d | | | --ai-instructions or -ai | | | --reset-confirmed | | | --retain-confirmed | |

Notes

--api-key Your project API key (Can also be set using environment variable I18NEXUS_API_KEY)

--pat A personal access token that you have generated in your i18nexus account (Can also be set using environment variable I18NEXUS_PERSONAL_ACCESS_TOKEN)

--namespace The new namespace of the string

--key The new key of the string

--value The new value of the string

--details The new details of the string

--ai-instructions Instructions or context for AI machine translator

If you are updating the value of a string that contains translations that have been marked confirmed in i18nexus, you will be required to include one of the following options to your command:

--reset-confirmed Confirmed translations of this string will be reset with machine translations of the new value

--retain-confirmed Confirmed translations of this string will be retained

Deleting strings

i18nexus delete-string <namespace> <key> or i18nexus d <namespace> <key>

i18nexus d common welcome_msg -k <PROJECT_API_KEY> -t <YOUR_PERSONAL_ACCESS_TOKEN>

The above snippet will delete the string welcome_msg from your common namespace, along with its associated translations.

Options

| Option | Required? | | ------------------- | --------- | | --api-key or -k | ✔ | | --pat or -t | ✔ |

Notes

--api-key Your project API key (Can also be set using environment variable I18NEXUS_API_KEY)

--pat A personal access token that you have generated in your i18nexus account (Can also be set using environment variable I18NEXUS_PERSONAL_ACCESS_TOKEN)

Importing strings into your i18nexus project

i18nexus import <filePath>

i18nexus import ./en.json -ns common -k <PROJECT_API_KEY> -t <YOUR_PERSONAL_ACCESS_TOKEN>

The above snippet will read the contents of ./en.json and import them into the base language of your i18nexus project.

This is the equivalent of using the Import tool in the i18nexus web application. However, this CLI command only allows for uploading a JSON file for your base language.

Options

| Option | Required? | | ------------------- | --------- | | --api-key or -k | ✔ | | --pat or -t | ✔ | | --overwrite | |

Notes

--api-key Your project API key (Can also be set using environment variable I18NEXUS_API_KEY)

--pat A personal access token that you have generated in your i18nexus account (Can also be set using environment variable I18NEXUS_PERSONAL_ACCESS_TOKEN)

--overwrite If any keys already exist in the target namespace, overwrite the values with the imported values.

Adding new namespaces

i18nexus add-namespace <namespaceTitle>

i18nexus add-namespace common -k <PROJECT_API_KEY> -t <YOUR_PERSONAL_ACCESS_TOKEN>

The above snippet will create a new namespace in your i18nexus project with the title common.

Options

| Option | Required? | | ------------------- | --------- | | --api-key or -k | ✔ | | --pat or -t | ✔ |

Notes

--api-key Your project API key (Can also be set using environment variable I18NEXUS_API_KEY)

--pat A personal access token that you have generated in your i18nexus account (Can also be set using environment variable I18NEXUS_PERSONAL_ACCESS_TOKEN)