This version of CLI tool will be depreciated at November 1st 2020.
Use
Lokalise CLI v2 instead.

Automate file export and import with the Lokalise command-line tool, which acts as a wrapper for the Lokalise API and is built using The Go Programming Language. It is being distributed as a precompiled binary for different platforms and as a Docker image if you prefer to remain platform-independent. Source code is available as well.

Looking for usage examples? Check out the Filenames article.


Download

Mac OS

Download and install using Homebrew:

brew tap lokalise/brew
brew install lokalise

or grab the binaries:

lokalise-0.721-darwin-amd64.tgz
lokalise-0.721-darwin-386.tgz

Linux

lokalise-0.721-linux-amd64.tgz
lokalise-0.721-linux-386.tgz
lokalise-0.721-linux-ppc64.tgz

FreeBSD

lokalise-0.721-freebsd-amd64.tgz
lokalise-0.721-freebsd-386.tgz

Windows

lokalise-0.721-windows-amd64.tgz
lokalise-0.721-windows-386.tgz


Install

Decompress and put into any binary directory i.e. in PATH, for example /usr/local/bin

Run lokalise in the shell to see a list of global commands. Type lokalise help <command> to see help on a specific command.

You will need to generate a token to use with the CLI tool (or API). Open the Lokalise web dashboard, click your team icon in the top right corner, choose Personal profile and navigate to the API tokens tab. 


Config file

You have the option to create a /etc/lokalise.cfg  (or place it anywhere and specify --config option) containing your API token and (in case you have just one project) a project ID. For example, config file:

Token = "a1921f0903b5864b75fafbb1951b7defba49781f"
#Project = "3231527727690217e560f6.73199070"


Docker image

Those using the Docker environment may find it useful to have our command-line tool packaged as a Docker image, in case you require a platform-independent way to import and export data with Lokalise. See usage examples below.

Export from Lokalise to local directory

API_TOKEN=<your api token>
PROJECT_ID=<project id>
LOCAL_DIR=/tmp
FILE_FORMAT=json
docker run \
     -v ${LOCAL_DIR}:/opt/dest \
     lokalise/lokalise-cli lokalise \
     --token ${API_TOKEN} \
     export ${PROJECT_ID} \
     --type ${FILE_FORMAT} \
     --dest /opt/dest


Import local file to Lokalise

API_TOKEN=<your api token>
PROJECT_ID=<project id>
LOCAL_FILE=/tmp/en.json
LANG_ISO=en
docker run \
    -v ${LOCAL_FILE}:/opt/src/${LOCAL_FILE} \
    lokalise/lokalise-cli lokalise \
    --token ${API_TOKEN} \
    import ${PROJECT_ID} \
    --file /opt/src/${LOCAL_FILE} \
    --lang_iso ${LANG_ISO}



Usage

Global

COMMANDS:
     list, l    
        List your projects at Lokalise.

     export, d  
        Downloads language files.

     import, u  
        Upload language files.

     help, h    
        Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --token token  
       API token is required and can be obtained under your Personal
       profile page in Lokalise.

   --config file  
       Load configuration from file. Looks up /etc/lokalise.cfg
       by default.

   --help, -h    
       show help

   --version, -v  
       print the version
   


List projects

Lists your projects.

USAGE:
   lokalise --token TOKEN list

Example:

lokalise --token 7e02197486aa32a83e5c10fd1992568269c1531f list


Export from project

Downloads projects files. File formats for --type  parameter.

USAGE:
   lokalise --token TOKEN export PROJECTID --type TYPE

OPTIONS:
   --type value              
       File format (strings, xliff, plist, xml, properties, json,
       po, php, ini, yml, xls, ios_sdk, android_sdk). See
       https://lokalise.com/apidocs#file_formats for file format
       list (single value, required).

   --dest value            
       Destination directory on local filesystem (/dir)

   --unzip_to value
       Unzip downloaded bundle to a specified directory (/dir) and
       remove the .zip. Use --keep_zip to avoid the deletion.

   --keep_zip 0/1                
       Keep downloaded .zip, if --unzip_to is used. (0/1)

   --langs value            
       Languages to include. Don't specify for all languages.
       (comma separated)

   --use_original 0/1        
       Use original filenames/formats (0/1)

   --filter value            
       Filter by 'translated', 'nonfuzzy', 'nonhidden',
       'reviewed', 'last_reviewed_only' fields (comma separated)
 
   --bundle_structure value  
       .ZIP bundle structure. Allowed placeholders are %LANG_ISO%,
       %FORMAT%, %LANG_NAME%, %PROJECT_NAME%.

    --directory_prefix value            
       Directory prefix in the bundle (use with --use_original=1).
       See https://lokalise.com/apidocs#export

   --webhook_url value      
       Sends POST['file'] if specified (url)

   --export_all 0/1          
       Include all platform keys (0/1)

   --export_empty value      
       How to export empty strings (empty, base, skip)
 
   --include_comments 0/1    
       Include key comments and descriptions in the exported file (0/1)

   --include_description
       Include key descriptions only in the exported file (0/1

   --include_pids value      
       Other projects ID's, which keys to include in this
       export (comma separated)

   --include_tags value              
       Only include keys with these tags (comma separated)

   --exclude_tags value              
       Do not include keys with these tags (comma separated)

   --yaml_include_root 0/1  
       Include language ISO code as root key in YAML export (0/1)

   --json_unescaped_slashes 0/1  
       Leave forward slashes unescaped in JSON export (0/1)

   --java_properties_encoding value    
       Encoding for .properties files. (utf-8, latin-1)

   --java_properties_separator value  
       Separator for keys/values in .properties files. (=, :)

   --export_sort value      
       Key sort order (first_added, last_added, last_updated,
       a_z, z_a)  

   --replace_breaks 0/1      
       Replace link breaks with \n (0/1)

   --no_language_folders 0/1      
       Don't use language folders (0/1)

   --triggers value
       Trigger integration export. Allowed values are 'amazons3' and    
       'gcs' (comma separated)

   --repos value
       If a repo integration is triggered, specify to which repos the
       pull requests should go to. Don't specify for all. (comma
       separated).

   --plural_format value        
       Override default plural format.
       See https://lokalise.co/apidocs#pl_ph_formats (value).

   --icu_numeric 0/1
       Use =0, =1, =2 instead of zero, one, two plural forms. Works    
       with ICU plurals only. (0/1)

   --placeholder_format value    
       Override default placeholder format.
       See https://lokalise.com/apidocs#pl_ph_formats (value).

   --indentation value                
       Provide to override default indentation in supported files.
       (1sp, 2sp, 3sp, 4sp, 5sp, 6sp, 7sp, 8sp, tab)

   --escape_percent value            
       When enabled, all universal percent placeholders [%] will be
       always exported as %%. Only works for printf placeholder
       format ('0/1').

Example: 

lokalise --token 7e02197486aa32a83e5c10fd1992568269c1531f export 98305045592fb799a15d20.15846093 --type json --tags front,dash,admin


Import to project

Uploads local files to a project. You will need to engage the CLI tool several times if you want to upload multiple files.

USAGE:
   lokalise --token TOKEN import PROJECTID --file FILE --lang_iso VALUE

OPTIONS:
   --file File          
       A single file, or a comma-separated list of files or file masks
       on the local filesystem to import (any of the supported file
       formats) (required). Make sure to escape * if using file masks  
       (\*).

   --lang_iso value    
       Language of the translations in the file being imported.
       Applies to all files, if using a list of a file mask (reqired).

   --replace 0/1        
       Shall existing translations be replaced (0/1)

   --skip_detect_lang_iso 0/1
       Disable detecting and converting language code to %LANG_ISO% in
       filenames. (0/1)

   --convert_placeholders 0/1  
       Convert placeholders to Lokalise universal ones.
       https://docs.lokalise.co/developer-docs/universal-placeholders
       Enabled by default. (0/1)

   --fill_empty 0/1      
       If values are empty, keys will be copied to values (0/1)

   --icu_plurals 0/1    
       Enable to automatically detect and parse ICU formatted plurals
       (0/1)

   --distinguish 0/1    
       Distinguish similar keys in different files (0/1)

   --hidden 0/1            
       Hide imported keys from contributors (0/1)

   --tags value        
       Tags list for newly imported keys. By default tags are applied to
       created and updated keys. (comma separated)

   --tag_inserted_keys value        
       Add specified tags to inserted keys (comma separated)

   --tag_updated_keys value        
       Add specified tags to updated keys (comma separated)

   --tag_skipped_keys value        
       Add specified tags to skipped keys (comma separated)

   --use_trans_mem 0/1  
       Use translation memory to fill 100% matches (0/1)

   --include_path 0/1    
       Include relative directory name in the filename when uploading.  
       Do not need enable if path contains language code. (0/1)

   --replace_breaks 0/1    
       Replace \n with line breaks (0/1)

   --cleanup_mode 0/1          
       Enable to delete keys with all language translations from
       Lokalise that are not present in the uploaded files.  (0/1)

Example: 

lokalise --token 7e02197486aa32a83e5c10fd1992568269c1531f import 98305045592fb799a15d20.15846093 --file /myapp/locale/\*.json,/myapp/locale/admin/\*.json --lang_iso en --tags app2.0



Changes

0.72 (September 18, 2019)

  • updated API URL to .com

0.72 (August 22, 2019)

  • added skip_detect_lang_iso parameter to import.

0.71 (July 12, 2019)

  • added tag_inserted_keys, tag_updated_keys, tag_skipped_keys parameters to import.

0.70 (April 29, 2019)

  • added support for last_reviewed_only filter in export.

0.69 (December 12, 2018)

  • added support for i18n placeholder type
  • added support for i18next plural type

0.68 (December 12, 2018)

  • added support for raw placeholder type

0.67 (October 23, 2018)

  • added include_description export parameter.

0.66 (October 9, 2018)

  • added repos export parameter.

0.65 (September 4, 2018)

  • added cleanup_mode to import.

0.64 (August 9, 2018)

  • added support for 'indentation' option on export

0.63 (July 16, 2018)

  • added support for 'symfony' type of placeholders on export

0.62 (July 16, 2018)

  • added reviewed filter to export

0.61 (June 22, 2018)

  • increased import timeout.

0.60 (May 24, 2018)

  • added escape_percent switch to export.

0.59 (May 23, 2018)

  • fixed issue with android/ios bundle generation

0.581 (May 18, 2018)

  • fixed replace option typo.

0.58 (March 20, 2018)

  • added java_properties_separator and java_properties_encoding parameters to export

0.57 (March16, 2018)

  • added exclude_tags parameter to export
  • renamed tags to include_tags

0.56 (March 13, 2018)

  • added directory_prefix parameter to export.

0.55 (March 9, 2018)

  • added convert_placeholders parameter to import.

0.54 (March 6, 2018)

  • added include_path parameter to import.
  • various bugfixes

0.53 (March 1, 2018)

  • fixed file masks for import

0.52 (February 27, 2018)

  • added icu_numeric switch to export.

0.51 (February 23, 2018)

  • added plural_format and placeholder_format switches to export.
  • added icu_plurals switch to import.

0.49 (February 12, 2018)

  • If using unzip_to parameter, the .zip file will now be automatically deleted after the unzip finishes. Use --keep_zip parameter to avoid deletion.

0.48 (February 12, 2018)

  • Fixed a bug with android_sdk and ios_sdk format types.

0.47 (February 8, 2018)

  • Added export triggers parameter to initiate Amazon S3 or Google Cloud Storage integration export.

0.46 (February 5, 2018)

  • Added no_language_folders parameter. Useful if you don't want to create language folders in the target .zip.

0.45 (February 4, 2018)

  • Import multiple files at once. Now --file parameter supports comma separated list of files (e.g. --file mydir/file1.json,mydir/file2.json  ) and file masks (e.g. --file mydir/\*.json). You can combine list and masks (e.g. --file mydir/admin/\*.json,mydir/user/\*.json . Make sure to escape * in filemask.

0.44 (January 5, 2018)

  • Added json_unescaped_slashes parameter for JSON export. Enable to leave forward slashes unescaped.

0.43  (December 28, 2017)

  • Added unzip_to parameter to export. Set the folder to where the downloaded bundle should be unarchived.

0.420  (December 4, 2017)

  • Non-zero exit code for errors. The CLI tool will exit with exit code 5 if there is a CLI tool parameter error or with exit code 7 if there is an API returned error.
  • Bugfixes

0.412 (June 31, 2017)

  • Fixed support for Project directive in the config file (for the import function).

0.411  (June 1, 2017)

  • export_sort added to export
  • yaml_include_root added to export

0.4  (March 13, 2017)

  • replace_breaks supported for import and export
  • Bugfixes
Did this answer your question?