Keys belong to translation projects. If you are not familiar with Lokalise projects, we recommend checking out the Projects article. Pay special attention to the Learn how platforms, keys, and files are organized section to understand how your data is hosted and represented on Lokalise.
In this article, you'll learn how to get started with translation keys and platforms.
Translation keys 101
Translation keys are placeholders within the source code of any application—whether it's a website, mobile app, game, or desktop app. When the application is displayed to a user, these keys are substituted with the appropriate translation values based on the user's chosen language setting.
Consider this example from the Ruby on Rails framework:
<h1><%= translate("welcome") %></h1>
Here, welcome
is the translation key. Translations are typically stored in specialized files. For example, you might have a YAML file containing all the English translations:
welcome: "Welcome to the application!"
And another file for French translations:
welcome: "Bienvenue dans l'application !"
When a page is displayed to a user who prefers the English language setting, the key will be replaced with the actual English translation:
<h1>Welcome to the application!</h1>
If the user switches their language preference to Russian, they will see the message in Russian:
<h1>Bienvenue dans l'application !</h1>
Lokalise provides a streamlined platform for managing translation keys and values, enabling easy upload and download of translation files, among other features.
Translation key example
In the screenshot above, you can see the following:
export
— this is the translation key name. Every key must have a name, and ideally, all names should be unique in your app. It is possible, however, to create keys with identical names but different platforms.API
(a label with an orange background) — this is a tag assigned to the key. You can use tags to filter keys.A small Google Chrome icon — this key was assigned to the Web platform (see the Linking platforms section for more information).
To the right you can see English and French translations for this key. You can click on these translations to edit them. You can add more languages to the current project. Once a locale is added, new empty translation values will be added to each key.
Adding translation keys
To add new translation keys to your Lokalise project, you have a few options:
Upload a new translation file.
Use the key editor to create a single translation key and adjust its options as needed.
Use the Lokalise command line tool to add one or more keys.
Use the Lokalise APIv2 to add one or more keys.
Creating translation keys
The simplest way to create a translation key is by using our graphical user interface. To get started, open your Lokalise translation project and click Add key:
You'll be presented with the key editor where you can assign the key name, base language value, platforms, and other attributes. Learn more in the Key editor article.
Keys can also be created when uploading translation files, importing content from third-party services by using Lokalise apps, and when using certain API endpoints.
Note on quotas
In Lokalise, a key is an identifier for translations in all languages of a project. For example, if you have a key called name
and your project supports 3 languages, name
will have 3 different translations, one for each language:
You can have as many languages as you need in your project. There are no limits on the length of translations either. In other words, a key can have multiple languages with variable translation lengths.
There is, however, a limit on the number of keys you can have. This quota is set at the team level, meaning it counts all the keys across all projects within your current team. For more details, check out the Team quotas article.
Note on project types, file formats
"Classic" translation keys are common in file formats like JSON, YAML, XLIFF, and XLSX. For these, use the Web and mobile project type.
If you're translating file formats that don't use keys broadly, like DOCX, HTML, or IDML, go for the Ad hoc documents project type.
For translating content from third-party services like Contentful, Iterable, Marketo, and others, choose the Marketing and support project type.
In all cases, Lokalise will still represent your data as translation keys (e.g., DOCX content will be split by paragraphs). These keys will be reassembled into the correct format when exporting.
Note on key creation
In Ad hoc documents, translation keys are used only to temporarily represent your data. Under the hood, there are no "real" keys.
In Marketing and support projects, the underlying data structure is controlled by the third-party app you're connecting to Lokalise. We parse the imported data and display it as keys, but the initial source is the chosen third-party app.
Due to these specifics, when working with Ad hoc documents and Marketing and support project types, you won't see the Add key button.
To create a new key in Ad hoc documents, you'll need to edit your original document and re-upload it to Lokalise.
To create a new key in Marketing and support, you'll need to adjust your data on the third-party service and re-import it to Lokalise.
Linking platforms
One of the unique features of Lokalise is the ability to use similar keys across different platforms, reducing the amount of translation work for translators.
Currently, Lokalise supports four platforms:
Web
Android
iOS
Other
When you add a new key, it must be assigned to one or more platforms:
When you upload a translation file, all keys inside will automatically be assigned to the appropriate platform based on the file extension. For example, keys in a JSON file will be assigned to the Web platform.
To link an existing key to a platform, simply find it in the project editor, click on the platform icon, and choose one or more options:
Why link platforms to a key?
Assigning a key to a platform includes the key in the export routine for file formats compatible with that platform. For example, if a key is assigned to both iOS and Android platforms, it will be exported when Apple .strings
and Android .xml
formats are chosen. However, it would not be included in a Web .json
export (while keys with a Web platform would only go to a .json
export).
Here's a partial list of various file formats grouped by platforms that you can find on the Download page:
You can think of platforms as global tags for the keys. If you want all keys to be exported regardless of the platform (for example, if you want to export all data in Excel format), just turn on the Include all platforms option on the Download page:
Different key names for different platforms
Developing for different platforms often involves different key naming schemas. For example, iOS developers might prefer LoginButton
while Android developers prefer login_button
. Lokalise has a solution for this: enable the Per-platform key names option in project settings.
First, click More > Settings in the main menu:
Under the General tab, find the Miscellaneous section and tick the Per-platform key names setting.
Save the changes by clicking the corresponding button at the bottom of the page.
Once this is enabled, when you add a new key (or edit an imported one), you can set a unique key name for each platform.
In the screenshot above, the key is linked to two platforms, and you can switch between these platforms to provide different names.
It is not possible to provide different translations for the same language on a per-platform basis. You can create a single key and give it different names for iOS and Web, but this key cannot have different translations for the same language on iOS and Web.
If you need different translations for different platforms, create two separate keys.
Hidden and archived keys
If you are not done editing your original translation, you can mark the key as Hidden from contributors so that regular (non-admin) contributors can't see it and don't start translating it. Other project admins will still be able to see this key and its translations.
To archive keys so they are not visible in statistics, export, search, and similar areas:
Tick the checkboxes next to the names of the keys you want to archive.
Select Archive from the bulk actions dropdown.
To display all archived keys in the editor:
Click on the Filter dropdown and then New filter.
Set up a custom filter by choosing Key — is archived.
Press Apply to view only the archived keys.