Is it possible to translate some strings, but not all, in a separate resource file without Lint complaining about MissingTranslation?
For example: my app's strings are all in res/values/strings.xml. One of the strings is
<string name="postal_code">Postal Code</string>
Since "postal code" is usually called "zip code" in the US, I want to add another resource res/values-en-rUS/strings.xml with contents:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="postal_code">Zip Code</string> </resources>
However, Lint complains about other strings in values/strings.xml but not in values-en-rUS/strings.xml
I realize you can suppress the warnings by specifying tools:ignore
in values/strings.xml. But this is undesirable because the Lint warning is actually useful when translating to another language.
Instead, is it possible to suppress the warning in the values-en-rUS/strings.xml file, as in, telling Lint not to use that file as criteria when looking for missing translations?
A nice way to disable MissingTranslations check is to add the option in module specific build.gradle
file .
android { lintOptions{ disable 'MissingTranslation' } //other build tags }
If the strings are not present in locale specific Strings file, it will take the strings from the default file which generally is strings.xml
.
I found a better solution according to this answer: https://stackoverflow.com/a/13797364/190309
Just add ignore="MissingTranslation"
to your string.xml
, for example:
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation" > <!-- your strings here; no need now for the translatable attribute --> </resources>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With