Key referencing

Updated 3 months ago ​by Nick Ustinov

Using Lokalise placeholder

There are many cases when you have similar content in multiple strings, for example "Cancel" is one of the common examples. Usually projects have many keys for the Cancel button (as the translation may vary depending on the context for different languages).

You can easily solve this by linking or referencing one key from another. Use Lokalise placeholder to do this:


Inserting this placeholder would actually fetch source_key_name value for specific language (in the editor and when exporting).  Even more, you can use placeholder inside the text, or use multiple placeholders in the same field:

Would you like to [%key:button_cancel%] or [%key:button_proceed%]?

Example above would produce the following result:

If you hover the mouse over dialog_title English value, you can click green key name itself to navigate to the source key or click any other area to edit it.

Linking duplicates using referencing

First, switch to language duplicate find view. To do so, click small language triangle on the dashboard and choose "Show duplicates".

In the duplicates view, there is an option to link the keys one by one (make sure to select the "main" one first) or link 'em all using the button on top.

Referencing all languages

So, you are done with base language duplicate hunting and set references for all dupe translations. You can either repeat the process language by language, or use mass-action in the editor in order to apply it to all languages. Go to the editor, select all keys and choose Fill translations with references... from the floating box. This would look up all non-base languages of these keys and in case the content is empty and base language translation is linked to a key, it would do the same for all other languages.

How did we do