Best practice for language independent strings

My Android app contains a number of language independent strings such as rates and support phone numbers. I have placed an XML file in /res/values

containing, for example:

<string name="helpdesk_number">0900 12345678</string>
<string name="helpdesk_tariff">60p</string>
<string name="helpdesk_address1">221B Baker Street</string>
<string name="helpdesk_address2">London NW1 6XE</string>

      

Lint complains that these lines are not translated into other languages:

Locale de lacks translations for: helpdesk_number, helpdesk_number, helpdesk_address1, helpdesk_address2 ... (56 others)

While it makes sense to display a different rate for other languages, the support team is located in only one country.

Does it make sense to copy these lines to other languages? Or is there a way for Lint to ignore those specific lines (or a line file)?

+3


source to share


6 answers


the upcoming (hopefully soon) ADT17 will bring some functionality to ignore some of the lint warnings:

http://tools.android.com/recent/ignoringlintwarnings

http://tools.android.com/tips/lint/suppressing-lint-warnings

so with ADT 17 you can put lint.xml in your project folder containing:

<issue id="MissingTranslation" severity="ignore" />



or perhaps you can also do it per line with:

tools:ignore="MissingTranslation"

but the doc is not 100% clear about this, and I don't have time to do the 17 test at the moment.

A Follow-UP: ADT17 was released shortly after you asked and should solve your problems!

+5


source


In recent versions of Lint, you can ignore the specific "MissingTranslation" lines :

strings.xml



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

    <!--suppress MissingTranslation -->
    <string name="some_string">ignore my translation</string>
    ...

</resources>

      

http://tools.android.com/tips/lint/suppressing-lint-warnings

+4


source


Straight from the Lint tool:

If the string does not need to be translated, you can add the translatable = "false" attribute on the element, or you can define all of your untranslated strings in a resource file called donottranslate.xml. Or you can ignore the problem using the tools: ignore = "MissingTranslation".

Just create a "donottranslate.xml" file inside the default res / values ​​folder and Lint will ignore it. I put all my app keys / IDs, etc. Here, as well as the settings, since they do not need to be "translated" and simply take up space in other files.

+3


source


another way to avoid this message is by adding to the resource file:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">

      

+3


source


 > Best practice for language-independent strings

      

In my application I have two strings file files, one of them is called "NonTranslatabable.xml", which will receive those strings that will not be translated (username, filenames, ..).

When translating an application into another language, I don't have to think if the string should be translated or not.

+1


source


Add this to your Gradle app file under "android"

lintOptions {
    disable 'MissingTranslation'
}

      

0


source







All Articles