3

My Android application contains a number of language-independent strings, such as tariffs and support phone numbers. I've placed a XML file in /res/values containing for instance:

<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 is complaining that these strings aren't translated to the other languages:

Locale de is missing translations for: helpdesk_number, helpdesk_number, helpdesk_address1, helpdesk_address2... (56 more)

While it might make sense to display a different tariff for other languages, the helpdesk is only in one country.

Does it make sense to copy these strings to the other languages? Or is there some way of having Lint ignore these specific strings (or string file)?

Bananeweizen
  • 21,797
  • 8
  • 68
  • 88
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187

6 Answers6

5

the upcoming ( hopefully soon ) ADT17 will bring some features for ignoring some lint warnings:

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

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

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

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

or perhaps you can also do it per string via:

tools:ignore="MissingTranslation"

but the document is not 100% clear about that and I have no time for betatesting 17 at the moment ..

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

ligi
  • 39,001
  • 44
  • 144
  • 244
4

In recent versions of Lint, you can ignore specific "MissingTranslation" strings like this:

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

Eduard
  • 3,482
  • 2
  • 27
  • 45
3

Straight from the Lint tool:

If the string should not be translated, you can add the attribute translatable="false" on the element, or you can define all your non-translatable strings in a resource file called donottranslate.xml. Or, you can ignore the issue with a tools:ignore="MissingTranslation" attribute.

Just create a file "donottranslate.xml" inside your default res/values folder and Lint will ignore it. I put all of my app keys/ids and such in here as well as preferences, since those don't need to be "translated" and just taking up space in other files.

thunsaker
  • 854
  • 5
  • 11
3

other way to avoid that message, adding to your resource file:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
1
 > Best practice for language-independent strings

In my app i have two string resource files, one is named "NonTranslatabable.xml" that will receive those strings that will not be translated (appName, fileNames, ..).

When translating the app into an other language, i donot have to think, if a string must be translated or not.

k3b
  • 14,517
  • 7
  • 53
  • 85
0

Add this into your Gradle App file under 'android'

lintOptions {
    disable 'MissingTranslation'
}
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Leonardo Rignanese
  • 865
  • 11
  • 22