⌨️CLI / Command-line interface

Transiyzi CLI lets you upload or download translations directly to your app, integrating with your build chain or CI/CD process.

Installation

The Transiyzi CLI is available on NPM repository as transiyzi/transiyzi-cli.

Install using npm

npm install -g @transiyzi/transiyzi-cli

Usage

Run transiyzi --help from the terminal to see the list of commands and subcommands. Run transiyzi command --help to see the help page.

Commands

transiyzi init

It is used to create the transiyzi.json file that holds your project settings.

transiyzi.json
{
    "access_token": "",
    "project_id": "",
    "base_path": "./resources/lang",
    "upload": {
        "locales": []
    },
    "download": {
        "default_format": "JSON",
        "include_unreviewed_translations": false,
        "aliases": {}
    }
}
  • access_token can be generated from the "Access Tokens" section in your profile settings.

  • After the init command, enter the access token and select from the list of authorized projects.

  • The default_format selects the format for exporting non-file-specific keys during download from the given list.

  • The base_path is the main directory where the language files are located, starting from the directory where the transiyzi.json file is located. For example: "./resources/lang".

    • NOTE: The path should not start from the OS root.

    • Incorrect usage: "/resources/lang".

transiyzi upload

It reads the definitions in the upload key of the transiyzi.json file and performs an upload.

  • The path written represents the structure after the base_path parameter.

  • The locales must match a language that exists in the project. When defining them, it is important to pay attention to the ISO code selected for the project, i.e., en !== en-US.

  • If the project can access files through a single structure, it should be defined as a string. If multiple templates are required, it should be defined as a string array.

  • The ** used in the path corresponds to any folder under the relevant folder.

  • The * used in the path can be used to define the filename, foldername, or extension.

  • The or statement can be used in the path with the pipe symbol. Multiple formats can be defined this way. For example: (php|json|xlsx).

  • The locales.code in the path corresponds to language code.

  • update_translations in the API documentation corresponds to the same parameter in the import endpoint. Default value is false.

  • If a different variable other than is desired, the code_alias parameter can be added to the locale object. An example is shown below. Now, <locale-code> === "English":

transiyzi.json
{
    "upload": {
        "locales": [
            {
                "code": "en",
                "path": [
                    "**/<locale-code>/**/*.(php|json)",
                    "**/<locale-code>.(php|json)"
                ],
                "update_translations": true
            }
        ]
    }
}
transiyzi download

It reads the definitions in the download key of the transiyzi.json file and performs a download.

  • format in the API documentation corresponds to the same parameter in the import endpoint. Default value is null.

  • The default_format in the API documentation corresponds to the same parameter in the download endpoint. Default value is JSON.

  • The include_unreviewed_translations in the API documentation corresponds to the same in the download endpoint. Default value is null.

  • The aliases parameter is used to make changes to the foldername or filename of downloaded files. In the example below, the downloaded file "./en/auth.php" is saved as "./default/auth.php"

{
    "access_token": "",
    "project_id": "",
    "base_path": "./resources/lang",
    "upload": {
        "locales": [
            {
                "code": "en",
                "path": [
                    "**/<locale-code>/**/*.(php|json)",
                    "**/<locale-code>.(php|json)"
                ],
                "update_translations": true
            }
        ]
    },
    "download": {
        "default_format": "JSON",
        "include_unreviewed_translations": false,
        "aliases": {
            "en": "default",
            "es": "spanish",
            "de": "german"
        }
    }
}

Last updated