This is a common situation when you are developing an app for two or more platforms - iOS, Android, web, IoT etc. plus, some key names and values are the same and some are different. Lokalise can help you to avoid repetitive translation work and keep your project clean by merging keys. 

First, there is a unique feature in Lokalise which lets you have the same key with different key names for different platforms. Different platforms usually involve different naming schemas, e.g. iOS coders would prefer LoginButton, while Android coders are keen on using login_button. Lokalise has the solution for this never-ending battle. You can enable this feature by going to the project Settings and enabling the Per-platform key names option.

Next, follow the iOS and Android example below to merge your existing keys for any two or more platforms.

Step 1: Merging keys with similar names

Some of the keys in your iOS and Android projects may already have the same names, e.g. both platform developers named a key AgreeButton. Such keys are merged by Lokalise automatically during the upload and import processes.

To keep it easy, start with a blank project. Upload the base language files of your iOS app and then upload the base language files of your Android app. You can do it the other way around too, the sequence does not matter.

At this step Lokalise will merge keys with the same names, e.g. when your iOS and Android language files contain a key welcome.title, they would be automatically merged to a single key entry that is linked to both iOS and Android platforms.

It is important to understand that this single key entry would have just one translation value for each language. In other words, if you have had the same key names with different translation values, the result of merging them would be the translation value from either the first or the second file you upload and import, depending our your import settings, so please be careful there.

Remember, linking a key to a platform means including this key in the export of the file formats associated with the platform (i.e. if you assign a key to an iOS platform, it would get included with the .strings file export and not with the .xml export).

Click the platform icons in the editor to quickly assign/unassign platforms.

Step 2: Merging keys with different names but the same translations

In most cases key names will be different. Here is how to merge them based on the same translation value. 

In the projects dashboard, click the three dots next to the base language name and choose Show duplicates.

The duplicates view allows you to merge keys and to link keys. 

Key merging actually creates a single key entry out of several. This key entry may have different key names per platform, but the same translation. 

In turn, key linking would still keep two key entries but create a reference from one key to another. Think of it as hyperlinks within the project.

This applies to cases where the keys do not have the same name as in Step 1. The following are the requirements two keys should meet first in order to be merged:

  • each key has just one platform assigned to them
  • both keys have the same translation value (in the base language)
  • there is only one key with that translation value per platform

As you can see in the example above, the system would not allow the next_button, button_next and the NextButton keys to merge. The reason is that a merged key entry can only hold up to one key name per platform.

The solution would be first to uncheck all platforms leaving just iOS in the header bar (only the iOS keys will be shown in the duplicates view). Now you can link next_button to button_next (or vice versa). 

Next, when you re-select the checkboxes for all the platforms, the system will allow you to merge NextButton and next_button.

Finally, as you now have only one key containing the translation value "Next" for each platform, it is safe to merge all keys.

Click Merge all possible keys, or merge one by one.

The same procedure applies to the process of merging iOS and Web, Android and Web, or any other combination of platforms.

Did this answer your question?