In this article you'll learn how to get started with translation keys and platforms.

Note: 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.

Index

Translation keys 101

Translation keys act as placeholders inside the application source code. It can be any application: website, mobile app, game, desktop app, and so on. When the application is served to the user, translation keys are replaced with the corresponding translation values based on the user's preferred locale.

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 YAML 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>

Lokalise enables you to 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 translation key name. Every key must have a name and ideally all names should be unique in your app.

  • figma (a label with a purple 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 Russian 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

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 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?