Filenames

Lokalise is a project-based platform, which means we do not keep files as logical entities. There are two ways to group data by filenames when you are exporting.

Option 1. All keys to a single file

For most projects, this is the recommended option. All you need to do is select the file format. You have the option to configure an exported .zip structure and filename as required, using flexible placeholder options For example, setting the structure to
locale/%LANG_ISO%.%FORMAT%
would produce the following structure:

locale/en_US.json
locale/ru_RU.json
locale/fr.json


Option 2. Use previously assigned filenames 

If you need to split keys across multiple files select this option. There are several things to pay attention to:

  • When importing a file, keys are automatically assigned to filenames.
  • Keys can be assigned to different filenames by platform (this is useful if you share keys between platforms, e.g. Cancel button text). For example, you can assign a key to frontend.json on Web and strings.xml on Android.
  • If you need to rotate language codes in the filenames, use the %LANG_ISO% placeholder in the filename, e.g. backend_%LANG_ISO%.%FORMAT%
  • Adding a new key via a web interface or API, you can either keep it as unassigned to a filename or assign to an existing / create a new filename.

If you did not pay attention to filenames while uploading, it's easy to fix. If certain keys are not going to the files as you expect, just navigate to project editor, click the affected key name to bring up the key editor, navigate to the Advanced tab and make sure the Filename assignment is correct for the export platform. If there is a language code that should be rotated in the filename on export, just click "Rename filename" and use the %LANG_ISO% placeholder instead of a hard-coded language code.

Looking for CLI tool upload/download examples? Check out the Filenames article.

Webhooks

Webhooks are assigned per-project and per-user, meaning if you share a project with another owner, the other person will not have the same webhooks or export options you set up for the project. If you need to share the webhook settings with other project users, simply use the sidebar chat.

Once a webhook fires (once the export has been performed), the request is sent to a specified URL. Lokalise sends the HTTP POST['file'] to the URL you specified. For security reasons only the filename is sent, so you need to add https://s3-eu-west-1.amazonaws.com/lokalise-assets/ before filename when pulling data. Here is a sample PHP script for pulling and unzipping the bundle:

<?php
// requires php curl
$url = 'https://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_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.";
}
Did this answer your question?