Now Paging Maciej

    i18nexus-cli

    3.1.0 • Public • Published

    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. Learn more with this quick Next.js walkthrough or this React.js walkthrough.

    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 and libraries such as next-i18next).
    • 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 or mobile 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 in the following structure:

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

    This structure is i18next convention, and will work by default with next-i18next.

    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 ./public/locales
    --ver or -v latest
    --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)

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

    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)

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

    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)

    Install

    npm i i18nexus-cli

    DownloadsWeekly Downloads

    1,716

    Version

    3.1.0

    License

    MIT

    Unpacked Size

    23.3 kB

    Total Files

    13

    Last publish

    Collaborators

    • i18nexus