This tutorial will explain how to add comments to translators when translating Android apps.
Android has XML resource files. XML supports comments, but these are easily lost when processing and manipulating resources.
Instead of using the native XML comments, we’ve defined comment attributes, which can be part of the XML.
To add a comment to a regular string, add the comment attribute to it. For example:
<string name="quote_button" comment="Button label to produce a cost calculation">Quote</string>
The word ‘Quote’ has different meanings. It can be ‘how much something costs’ or ‘what someone said’. Without knowing the context, translators can come up with incorrect work. Sometimes it’s amusing, but not when it’s on your app.
By adding a comment, you’re explaining the translator what it means and how it’s used.
You can do the same for plurals and arrays.
<string-array name="foods" comment="Food classes"> <item>Salad</item> <item>Fish</item> <item comment="generalize for meats that are not beef">Chicken</item> <item commentadd="Refers to vegetables">Vegies</item> </string-array>
<plurals name="number-of-dishes" comment="all the names"> <item quantity="one">Dish</item> <item quantity="other" comment="Several dishes">Dishes</item> </plurals>
There are several options to add comments to arrays and plurals.
- The same comment to all items – add a comment attribute to the parent string-array or plurals tag.
- Individual comment per item – add a comment attribute to the child item. This will override a parent comment, if it exists.
- A general comment and additions per item – add a comment attribute to the parent and a commentadd attribute to children.
What translators see
When translators work on your project, they would see the comments that you’ve added, per string.
Do these comments interfere with Android OS?
Not at all. Android takes what it needs from the XML and ignores the rest.
Our system takes both the texts and the comments from the XML. The Android app simply ignores them.
Where could I find another reference for adding translation for Android, Thanks
Have you read our Android localization tutorial?
I think that language is an issue when we speal about android apps, many of them are english only, and some are for north america users only, we spect that this changes in time.