Recent Changes‎ > ‎

Non-translatable Strings

posted Aug 28, 2012, 2:47 PM by Tor Norbye   [ updated Feb 7, 2017, 8:36 AM by Scott Main ]
One of the things lint warns about is where you have a string, and it's not translated to all the languages you are targeting. However, in some cases you don't want to translate a string, for example because it's a proper name that should be the same across languages, or perhaps because you want to change it not across languages but for example between different device orientations.

There's a not so well known convention to deal with this: set the attribute translatable="false" on the <string> definition:
<string name="account_setup_imap" translatable="false">IMAP</string>

This attribute is similar to conventions used in various programming languages, such as the //NON-NLS-1$ marker comment found in Eclipse source code for example.

UPDATE: You can now use Android Studio's Translation Editor to configure your non-translatable strings:

In the next version of ADT 21, we're making this more obvious. Not only has the lint issue explanation been expanded, but there's now an Eclipse quickfix for the missing translation error as well:

Again, this attribute is just advisory. But in ADT 21 lint also helps make sure you're using it correctly. If a string is marked as non-translatable, and you do provide a translation in one of the other locales, then lint will complain:

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.

ADT 21 Preview 2 is available if you'd like to give this, and various other fixes and improvements, a try. (For comments or questions, follow up on this Google+ post)