That is a common situation when you are developing an app for two and more platforms - iOS, Android, web, IoT or any other, and some key names and values are the same and some are different. Lokalise can help you to avoid the repetitive translation work and keep your project cleaner 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 this iOS and Android example below to merge your existing keys for any two and 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.

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

At this step Lokalise would merge keys with 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.

You must understand that this single key entry would have just one translation value for every language. In other words, if you have had the same key names with different translation values, the result from 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 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 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 would be different. Here is how to get them merged based on the same translation value. 

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

The duplicates view allows you to merge keys and 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.

We are talking of the case 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 at the example above, the system would not allow to merge next_button, button_next and NextButton keys. The reason is that a merged key entry can only hold up to one key name per platform.

The proper 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 tick the checkboxes for all the platforms again, the system would 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.

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?