Skip to content →

Deploying Lokalise into your workflow – best practices

“How do I integrate Lokalise into my deployment process?” All your answers are here, in one place. Bookmark this page for handy links to the latest list of Lokalise integration tools.

General tips

GitHub integration

We love Github. But Lokalise is a project-based translation platform. We do not store files as such. We dynamically generate them at your request and deal with multiple export options, including the ability to filter only the required content and the file format itself. That’s the only reason we do not provide a direct integration with GitHub.

However, we provide an easy workaround to sync your files between Github and Lokalise. Combine our command line (CLI) tool to generate and export the bundle with the standard git command line client. Generate and download the bundle, unzip it and push to git with a simple bash script. Or do the reverse – pull the file from git and import to Lokalise using the command line tool.

lokalise --token <token> export <project id> --type json
unzip ./myapp.zip -d myproject/locale
cd myproject
git add .
git commit -c “Locale update”
git push

Hack your CI webhook

Constant export is not the only way to keep your Continuous Integrations (CI) up to date. Use a webhook instead. Go to project settings, navigate to Slack Integration tab and put your own URL there. Make sure it receives simple Slack-formatted payloads and performs the right actions by certain events.

Now next time you update a translation in Lokalise or modify a key, the CI webhook will automatically update them in all the right places.

iOS and Android

You can easily deliver text updates to end users who already have your Android or iOS apps installed. Here’s how:

Lokalise SDK

The best option to integrate Lokalise into your mobile apps is to use our SDK. It lets you seamlessly update your app strings over-the-air, without annoying users with unnecessary updates. SDK lets you generate bundle versions in Lokalise and enable them as “production” once they are ready. When the user opens your app, SDK automatically checks Lokalise for the latest bundle version. If it finds one, it instantly downloads the new bundle and updates all app texts.

Fastlane actions

If you are using workflow automation service Fastlane with iOS, check this. Our scripts let you automate the deployment process: import and export language files, add new keys to Lokalise or exchange app metadata with AppStore.

Lokalise CLI

If you prefer other delivery methods, use our Command-line (CLI) tool. It performs simple export and import between most software environments with a single line.

Web and software

Lokalise does not provide a content delivery network for web and software projects. You need to export the information from Lokalise and store (or process) it locally to serve your visitors and users.  Your localization methods may differ but the core release management and delivery principles stay the same. Here are some of your options:

Here are the most common options:

Webhooks

Webhooks are the easiest way to integrate Lokalise into your web app. Find them in Downloads page of your project or specify them as a parameter in API /project/export function.

Once the bundle is generated, the webhook fires and sends a POST request with file parameters to your specified URL. The file parameter is the relative location of the new generated bundle. You can now download it by adding https://s3-eu-west-1.amazonaws.com/lokalise-assets/ in front of your file. Here is a sample PHP code for the webhook script:

<?php
// requires php curl 
$url = 'http://s3-eu-west-1.amazonaws.com/lokalise-assets/' . $_POST['file'];
$local_file = '/tmp/langs.zip';
$extract_path = '/var/www/mysite.com/';
    
$zip = new ZipArchive;
$ch = curl_init(); 
$fp = fopen($local_file, "w");     
    
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
    
curl_exec($ch);
    
curl_close($ch); 
fclose($fp); 
    
if ($zip->open($local_file)) {
    $zip->extractTo($extract_path);
    $zip->close();
} else {
    echo "Could not download remote file.";
}

Important: if you are load-balancing your app at multiple instances, this method will not work.

Jenkins integration

If you are into continuous project delivery with Jenkins, use Lokalise command-line (CLI) tool. To run Lokalise CLI from Jenkins, set up an Execute shell task. Here is an example:

deploy/lokalise --token <token> export <pid> --type json
unzip -o myapp.com.zip -d app/public/locale

Docker

Look for our command line tool packaged as Docker image. Perfect if you need 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}

 

API

If simple imports and exports are not flexible enough for your case, use our API. It gives you more control over the project content: you can add or modify only certain keys, update some key translations in particular languages, add new tags to keys and more. API works via simple curl requests, the responses are JSON-formatted and easy to read and parse.

To manipulate your project content, use the /string/set API endpoint. To add new keys or update existing ones, use data payload. For example, if you only need to update tags on certain keys, use a payload like this:

[
   {
      "key": "app.slogan",
      "tags": ["main", "frontend"]
   },
   {
      "key": "app.user.online",
      "tags": ["backend"]
   },
   {
      "key": "show.projects",
      "tags": ["user", "backend"]
   }
]

Often it is easier to parse JSON than unzip the bundle. To generate one, use /string/list API endpoint and adjust parameters as needed. It will produce a JSON object, which you can then parse and store in a local database. Remember, you don’t need to use /string/list every time a visitor comes to your site, as Lokalise does not operate as a content delivery network.

Framework integrations

Everyone loves ready-made integrations. Here are our favorites, built over Lokalise API:

Symfony

Symfony bundle receives a webhook from lokalise.co and uploads the latest translation files into your directories.

CakePHP

Plugin for CakePHP lets you extract, pull and push language files to Lokalise right from your command line.

Laravel

This plugin lets you use php artisan lang:push and php artisan lang:pull to automatically push your base language and import your translations to and from Lokalise.

Django

Webhook-type of integration. Plug it into your project to download and store translations locally every time you fire a webhook at Lokalise.

Grunt

This plugin for Grunt that provides a command line interface for syncing your i18n files.