Keys and platforms

Learn how to properly set up and use keys and platforms in Lokalise.

Nick Ustinov avatar
Written by Nick Ustinov
Updated over a week ago

Keys belong to translation projects therefore if you are not familiar with Lokalise projects, it's really recommended to check out the Projects article. Specifically, we'd advise skimming through the Learn how platforms, keys, and files are organized section to understand how exactly 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 serve as 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, depending 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 Russian translations:

welcome: "Добро пожаловать в приложение!"

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>

Should the user switch their language preference to Russian, they will see the message in Russian:

<h1>Добро пожаловать в приложение!</h1>

Lokalise provides a streamlined platform for managing translation keys and values, enabling easy upload and download of translation files, among other features.

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.

  • 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.

To add new translation keys to your Lokalise project you have a few options:

Creating translation keys

The simplest way to create a translation 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 key name, base language value, platforms, and other attributes. Learn more about the key editor in the corresponding guide.

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.

Linking platforms

One of the unique features of Lokalise is the ability to use similar keys across different platforms, thus reducing the amount of translation work to be done by translators.

Currently Lokalise supports four platforms:

  • Web

  • Android

  • iOS

  • Other

Once you add a new key, it has to be assigned to one or several platforms:

When you upload a translation file, all keys stored inside will be automatically assigned to a proper platform based on the file extension. For example, keys stored inside a JSON file will be assigned to the Web platform.

To link an existing key to a platform, simply click on the platform icon and choose one or more options:

Assigning a key to a platform actually means including the key in the export routine for the file formats compatible with this platform. For example, if the 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 go to 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. In case you want all the 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 usually involves different key naming schemas, for example iOS coders would prefer LoginButton key name, while Android coders are keen on login_button. Lokalise has the solution to this never-ending battle: enable the Per-platform key names option in project settings. To achieve that, click More > Settings in the main menu:

Next, under the General tab find the Miscellaneous section and tick the Per-platform key names setting:

Don't forget to save the changes by clicking the corresponding button at the bottom of the page.

Next, once you add a new key (or edit the imported one) there is an option to set a unique key name on a per-platform basis. 

In the screenshot above the key was linked to two platforms, and you can switch between these platforms to provide different names.

Please note that it is not possible to provide different translations for the same language on a per-platform basis. In other words, you can create a single key and give it different names for iOS and Web, but this key cannot have different iOS and Web translations for English language. If your key must contain different translations for different platforms, then you will have to 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. Please note that other project admins will be able to see this key and its translations.

You may want to archive keys so they are not visible in statistics, export, search, and similar areas. To archive one or more keys, tick the checkboxes next to their names, and then select Archive from bulk actions dropdown:

Archived keys can be found by choosing "Archived" in the Filter dropdown.

Did this answer your question?