Hi,
We want to use the Lokalise tool as an external tool for our translators. Therefore, I exported the String table collection to .xlf in the Unity Editor. However I see that this export creates random ids instead of using the key that is provided in the table.
As a result, when I upload this .xlf file in Lokalise, it shows that generated id as the key while it should show the same key as in Unity.
Is there a way to customize this export to not generate ids but use the key of the String table collection instead?
Thanks
Chloë
Those arent random ids, they are the stable id values for the entry. Guranteed not to change unlike the entry name which can be changed at any time.
An XLIFF translation unit includes an id and name. The id is our generated ID value and the name is the key. Is Lokalise able to show the entry name instead of the ID?
For example:
XLIFF 1.2
<trans-unit id="6633451520" resname="MSG_1">
<source>Hello</source>
<target>Hola</target>
</trans-unit>
XLIFF 2.0
<unit id="6633451520" name="MSG_1">
<segment>
<source>Hello</source>
<target>Hola</target>
</segment>
</unit>
If it has to be the Key then there are 2 options:
- Modify the package
- Write a custom export/import
The simplest would be to modify the package. You can copy it from the PackageCache into the project Package folder.
Then change com.unity.localization\Packages\com.unity.localization\Editor\Plugins\Xliff\Xliff.cs
Line 199 assigns the ID, you can change it to assign the Key like line 200.
Next you need to change the import code.
Line 641 - GetOrCreateEntryFromTranslationUnit
Change line 665 from if (!string.IsNullOrEmpty(unit.Name))
to if (!string.IsNullOrEmpty(unit.Id))
Remove Lines 643-662.
Hi Karl,
Thanks for the quick reply. Thanks for sharing this page about the id values of the documentation, I overlooked that one.
I asked the Lokalise support whether I can specify the field they should use for the key. I’m awaiting their reply.
In the meantime, I’ll try to modify the package like you suggested.
1 Like
@karl_jones I just got a reply from the Lokalise support team that it is not possible to use the entry name. If we want that, we have to adjust the XILFF file before uploading it to Lokalise.
It would be nice if this could become an export setting in Unity. In the meantime, we can adjust the files ourselves before uploading it to Lokalise.
Thanks for the help!
Ah thats a shame. Ill add a task for us to add some more options to XLIFF so we can support this in the future.
Thanks for checking with Lokalise.