Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>

like image 913
Aditya Naique Avatar asked Oct 04 '15 14:10

Aditya Naique


2 Answers

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>
like image 147
Ismail Ceylan Avatar answered Nov 10 '22 13:11

Ismail Ceylan


Referring to the Android Studio Project Site:

If you have a lot of resources that should not be translated, you can place them in a file named donottranslate.xml and lint will consider all of them non-translatable resources.

like image 26
Felix Edelmann Avatar answered Nov 10 '22 14:11

Felix Edelmann