Localize CLI

The Localize CLI makes it easy to translate content from mobile apps and backend services. With a simple push/pull paradigm, you can easily push content to Localize and then pull the translations.

Installation

There are a number of different ways to install the Localize CLI on your machine, depending on what operating system and environment you are using. Here we describe how to install the Localize CLI using Pip.

Pip is a Python-based tool that offers convenient ways to install, upgrade, and remove Python packages and their dependencies. Pip is the recommended method of installing the CLI on Mac and Linux.

Prerequisites

  • Windows, Linux, OS X, or Unix
  • Python 2 version 2.6.5+ or Python 3 version 3.3+
  • Pip

Install Python

First, check to see if you already have Python installed:

$ python --version

If you don't have Python installed, follow the procedure at Install Python to set it up.

Install Pip

Next, check pip:

$ pip --help

If you don't have pip installed. follow the procedure at Install pip.

To install pip on Linux

Download the installation script from pypa.io:

$ curl -O https://bootstrap.pypa.io/get-pip.py

The script downloads and installs the latest version of pip and another required package named setuptools.

Run the script with Python:

$ sudo python27 get-pip.py
Collecting pip
  Downloading pip-6.1.1-py2.py3-none-any.whl (1.1MB)
Collecting setuptools
  Downloading setuptools-15.0-py2.py3-none-any.whl (501kB)

Installing collected packages: pip, setuptools
Successfully installed pip-6.1.1 setuptools-15.0

Invoking version 2.7 of Python directly by using the python27 command instead of python ensures that pip is installed in the proper location, even if an older system version of Python is present on your system. If the system version is supported you can just use python.

📘

Python Executable Name May Vary

The name of the Python executable may vary depending on your package manager (for example, python2.7).

Install the Localize CLI

With Python and pip installed, use pip to install the Localize CLI:

Windows

pip install localize

To upgrade an existing Localize CLI installation, use the --upgrade option:

pip install --upgrade localize

Linux, OS X, or Unix

$ sudo pip install --ignore-installed localize
NOTE: The `--ignore-installed` option is not required for pip versions 9 and below, since these versions support the upgrading of dependencies.


[block:api-header]
{
  "title": "Configure the CLI"
}
[/block]

Before you can start using the Localize Command Line Interface, you must [sign up](https://app.localizejs.com/signup) for a Localize account (if you don't already have one) and set up your CLI environment.

### Provide Project and API Keys

1. Log into your Localize account and go to the [API Keys](https://app.localizejs.com/settings/organization/api-keys) section of your Organization Settings.

2. [Create a new API key](https://help.localizejs.com/docs/create-a-new-api-key). It can be scoped to a specific project but do not scope it to a specific method.

3. Open terminal and run the following:
$ localize config

It will then ask you for your project key which you can find at the bottom of the API Keys page.

It will then ask for your API token, which you can find by clicking view next to the API key you made in step 1.

Add Path/Filenames

  1. Find and open the localize config, should be at the root of your user folder, on OS X/MacOS it is here: $HOME/.localize/config.yml.

a. Add your pull and push files.

api:
  project: YOUR_PROJECT_ID
  token: YOUR_PRIVATE_KEY
pull:
  targets:
  - file: /FULL_PATH_TO_FILE/LANGAUGE_CODE.EXTENSION
push:
  sources:
  - file: /FULL_PATH_TO_FILE/LANGAUGE_CODE.EXTENSION

b. Replace the - file: value under push: with the absolute path to your source file. You can have many source files by adding a new - file field.

c. Replace the - file: path under pull: with the absolute path to your new translated file. You can have many source files by adding a new - file field.

📘

Notes

  • For the pull file, the name can only be an active language code in that project. You do not need to create this file.
  • The file name MUST be in the format LANGAUGE_CODE.EXTENSION, no other file name will work. e.g.:
    • es.csv, fr.yaml, etc.

Usage

This section introduces the common features and calling patterns used throughout the Localize Command Line Interface.

Pull

To pull translations from your Localize account and replace the files in your pull directive, run the pull command.

localize pull

Push

To push phrases and translations into your Localize account, run the push command. This command will look at each file in your push directive to get the content.

localize push

Updated 2 months ago


Localize CLI


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.