Translation keys 101

Translation keys act as placeholders inside the application source code. When the application is served to the user, these translation keys are replaced with the corresponding translation values based on the currently chosen language.

Take a look at the following example taken from Ruby on Rails framework:

<h1><%= translate("welcome") %></h1>

In this example welcome is the translation key. All translations are usually stored in special files. For instance, you can have a file with all English translations:

welcome: "Welcome to the application!"

And a separate file with Russian translations:

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

When this page is served to the user who has chosen English locale, the key will be replaced with the actual translation:

<h1>Welcome to the application!</h1>

If the user switches the language to Russian, s/he will see the text in Russian:

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

On Lokalise you can easily manage translation keys and values, upload and download translation files, and many more:

In the screenshot above you can see the following:

  • registration.welcome_to_lokalise — this is the name of your translation key.

  • figma (with purple background) — this is a tag assigned to the key.

  • A small Google Chrome icon — this key was assigned with the Web platform (see below for more information).

  • To the right you can see English and Russian translations for this key. You can click on these translations to edit them.

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

Assigning 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. Once you import or add keys, they need to be assigned to one or several platforms. Currently Lokalise supports four platforms:

  • Web

  • Android

  • iOS

  • Other 

To assign 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 would be exported to Apple .strings and Android .xml, 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 the case that you want all the keys to be exported regardless of the platform (e.g. you need to export all to Excel), just turn on the Include all platforms option on the Download page:

Different keys for different platforms

Coding for different platforms usually involves different 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 Per-platform key names option in project settings. To achieve that, click More > Settings:

Under the General tab find the Miscellaneous section and tick the Per-platform key names setting:

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

In the screenshot above the key assigned with two platforms, and you can switch between them to provide different names.

Hidden and archived keys

If you are not done editing your original translation, mark the key as "Hidden from contributors" so contributors can't see it and don't start the translation. Note, that other project admins will see this key and its translations.

You may want the option 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:

Did this answer your question?