“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
If you are using GitHub, set up the integration in your project settings. It allows you to exchange files with your GitHub repository – automatic pull webhook is provided with each integration. Add it to GitHub repo settings and you are set. You can trigger pull request creation when exporting as well. Read the integration docs.
Webhook integration
Constant export is not the only way to keep your Continuous Integrations (CI) up to date. Use a webhook instead. Go to project settings > Integrations and enable Webhook integration. Read the integration docs.
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. Some of your options are listed below.
Lokalise CLI
The most popular (and the easiest) way to integrate Lokalise with your web app is to use Lokalise CLI tool to perform import/export procedures. For web apps, web backends, your API, RoR, Symfony, Django (you name the framework here) the principle stays the same – you need to pull latest translations from Lokalise and serve to your customers on your own from a local (and preferrably cached) source.
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.