Aditya Naik Aditya Naik - 4 months ago 15
Android Question

Attribute translatable="false" to the root <resources> element?

I have some strings of chemical names in a single

values/fertilizers.xml
file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="grade_dap">Diammonium phosphate - DAP (18:46:00)</string>
<string name="grade_ssp">Single super phosphate - SSP (00:16:00)</string>
...
</resources>


Now since all these strings in this file shouldn't be translated, can I put a single
translatable="false"
attribute to the root
<resources>
element, or do I have to put it for all the individual string elements like so:

<string name="grade_dap" translatable="false">Single super phosphate - SSP (00:16:00)</string>

Answer

If you want to use it to avoid lint warnings, you can simply put MissingTranslation attribute to cover them all.

<?xml version="1.0" encoding="utf-8"?>

<resources
  xmlns:tools="http://schemas.android.com/tools"
  tools:ignore="MissingTranslation">

  <string name="grade_dap">Diammonium phosphate - DAP (18:46:00)</string>
  <string name="grade_ssp">Single super phosphate - SSP (00:16:00)</string>
  ...
</resources>
Comments