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.
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:
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.
- Windows, Linux, OS X, or Unix
- Python 2 version 2.6.5+ or Python 3 version 3.3+
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.
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. The name of the executable may vary depending on your package manager (for example, python2.7).
Install the Localize CLI Using pip
With Python and pip installed, use pip to install the Localize CLI:
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 localize
Before you can start using the Localize Command Line Interface, you must sign up for a Localize account (if you don't already have one) and set up your CLI environment.
Log into your Localize account and go to the API Keys section of your Organization Settings.
Create a new API key. It can be scoped to a specific project but do not scope it to a specific method.
Open terminal and run the following:
$ localize config
It will then ask you for your
project keywhich 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.
Find and open the localize config, should be at the root of your user folder, on OS X/MacOS it is here:
api: project: YOUR_PROJECT_ID token: YOUR_PUBLIC_KEY pull: targets: - file: /FULL_PATH_TO_FILE/LANGAUGE_CODE.EXTENSION push: sources: - file: /FULL_PATH_TO_FILE/LANGAUGE_CODE.EXTENSION
- file:value under
push:with the absolute path to your source file. You can have many source files by adding a new
- file:path under
pull:with the absolute path to your new translated file. You can have many source files by adding a new
Note: For the
pullfile, the name can only be an active language code in that project. You do not need to create this file.
This section introduces the common features and calling patterns used throughout the Localize Command Line Interface.
To pull translations from your Localize account and replace the files in your
pull directive, run the pull command.
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.