Create a file format to extract translatable content in Attributes
If you would like to practice
If you open a XML in Studio and you don’t see anything for translating, it might mean that the translatable content in your XML file has been prepared as attribute values rather than in element:
If this is the case, you will need to create a customized File Type so that Studio knows where this content is, and can make the content “Translatable”. This example is based on a simple XML file that looks like this:
1) In Studio- go to File > Options > File Type > New:
2) Choose “XML (Embedded Content)” or “XML (Legacy embedded). The process for this exercise is exactly the same. The difference between these two XML files types is how they support the handling of embedded content which is not relevant for this article:
3) Complete the indicated fields + Next
4) In the window “Create File Type – XML Settings Import” > Choose “Define settings based on …” + Browse for your XML file + Next
5) In the next window just press Next
6) and now Finish
7) In the file type list we have now the new created type file > click on it in the left side of the list
8) Then click on Parser > Select the Rule and Remove them
9) We are going to create our own rules by clicking on Add > one for the XPath that will be “Not Translatable” and one for the Attributes” that will be “Translatable” + click OK
In this example the translatable text was contained in an attribute called “line” and this was within an element called “text”. It looked like this:
<text line="Soldier Freddy" /> (“Soldier Freddy” is the translatable text)
10) Then you will “Export Settings” and you will be able to “Import that Settings” to be used for another project or user.
11) If we click on Browse and chose our file + Preview > we see what we will have now in Studio:
And now in Studio it looks like this :
<?xml version="1.0" encoding="UTF-8"?> <atts> <title translate="n" >Soldier Freddy - Poem by Spike Milligan</title> <verse1> <text line="Soldier Freddy" /> <text line="was never ready," /> <text line="But! Soldier Neddy," /> <text line="unlike Freddy" /> <text line="Was always ready" /> <text line="and steady," /> </verse1> <verse2> <text line="That's why," /> <text line="When Soldier Neddy" /> <text line="Is-outside-Buckingham-Palace-on-guard-in -the-pouring-wind-and-rain-being-steady-and-ready," /> <text line="Freddy" /> <text line="is home in beddy." /> </verse2> </atts>