That’s a common situation when you are developing your app for two and more platforms – say, iOS and Android, and some key names and values are the same and some are different. Lokalise can help you to avoid double translation work and stay clean in general by automatically merging these keys.
One of the unique features of Lokalise is the ability to have key names exported differently depending on the platform. Coding for different platforms usually involves different naming schemas, for example iOS coders prefer “LoginButton”, while Android coders are keen for “login_button”. Lokalise has the solution for the never-ending battle. You can enable this feature by going to project Settings and enabling Per-platform key names option.
In the following example, follow these easy steps to merge your existing iOS and Android keys.
Step 1: Upload files to automatically link platforms.
Start with a blank project. You can either start by uploading iOS keys or Android keys, the sequence does not matter. Next upload second platform’s keys to the same project. At this step, Lokalise would link platforms for similar keys, e.g. if your iOS and Android source files contain a key with title login_button the project would end up with one key that is linked to both platforms.
If you already have the keys uploaded (or added manually), you would need to do this step manually.
Step 2: Merge by base language translation
In most cases key names would be different and here is how to get them merged by translation. Go to projects view and click small triangle near base language and choose Show duplicates.
This view shows duplicate translations for base language. Lokalise would also analyze the translation field and offers to merge keys, that could be merged.
Here are the conditions when keys can be merged:
- both keys have just one platform assigned
- both keys have identical translation
- there is only one key with that translation per platform
The third rule means, that if the translation is similar in more than one key, it cannot be merged, for example if translation Cancel appears on 3 keys Lokalise would not merge them, as that would require modifications in your code (we can only store one key per platform per entry). In order to fix this, you need to delete extra keys of Cancel, update your app code to refer to another key and then merge.
Feel free to hit Merge all possible keys button once you’ve reviewed the list.
Do not mix merging with key referencing. Link button actually creates references, but does not merge the keys.Same procedure applies to merging iOS and Web or Android and Web (or any other combination of platforms).