Often the same strings may appear at different places in your website or app. For example, you may have two "Next" buttons represented with
next_button translation keys. These keys, however, will have the same translation
Next meaning these keys are effectively duplicating.
In this case you will have to translate the same word twice. But Lokalise is here to help you identify and deal with such cases easily!
Opening Duplicate Finder
To get started, proceed to More > Duplicate Finder:
This tool is used to detect and take care of the duplicating keys.
You may also click on the specific language flag and select Show duplicates. This is going to find duplicates for the chosen language.
Duplicate Finder Controls
Using the top menu you may further adjust the detection options.
Language dropdown allows you to choose a language to search duplicates for.
Platforms sections allows you to select one or multiple platforms where the duplicates should be searched. By default, all platforms are chosen.
If any duplicates were found, they will be displayed for you:
Duplicate translation is the actual duplicated translation value.
Keys column lists all the translation keys that contain the duplicated translation value. You may click on the key name to open it in bilingual view.
For each key there are two buttons: Hide from contributors (only the project admins will be able to view the key) and Delete key.
Dealing With Duplicates
To take care of duplication, you may establish a link between keys. When a link (or reference) is created, one key becomes a parent (referenced key) while all other keys become children (referring keys). Thus, when translation for the referenced key is updated, the referring keys are updated automatically as well. When the translations are downloaded back, all linked keys will be exported properly along with their translations.
To link duplicating keys, simply click Link all to selected.
The chosen key (
cancel1 in the screenshot above) will become a referenced key while all other keys will become referring. If you want
cancel2 to become a referenced key, simply choose it by clicking a radio box next to its name.
If you have multiple duplicating entries, you may take care of them in one go by pressing Link all with references button. Do not forget to choose a referenced key for each found entry before clicking this button!
Once the operation is done, you will see that the referring translation is now highlighted with green.
Another common issue is having multiple keys with different names which are used on different platforms. For example:
CancelButton (iOS platform) and
cancel_button (Android platform). These keys, however, will probably have the same translation, for example
To avoid translating the same word multiple times, we can merge two keys to a single entry. To achieve that, press Merge to a single entry in the Duplicate Finder.
The duplicating keys will be merged to a chosen entry (
CancelButton in the screenshot above).
Alternatively, you may merge all found duplicates by pressing Merge all possible keys. Do not forget to choose entry to merge to by using radio boxes next to the key names!
After this operation is done, you will see that there is one key with different names for iOS and Android platforms.
Do not forget, however, that one key may have only one translation per language, so different platforms cannot contain different translations.
Another thing to note is that the merging operation will automatically enable the Per-platform key names option for the project. To toggle this option on or off, proceed to More > Settings and find the Miscellaneous section.
Automatically Merging Keys Upon Upload
Whenever you upload translation files, Lokalise is going to detect and take of certain duplicating keys. Specifically, if you have two translation files for different platforms, and these files contain similar keys, these keys will be merged to a single entry.
If you wish to preserve both keys without merging them, enable the Differentiate keys by file option before uploading translation files.