is it possible to specify that the strings in a file within the value-*
directories are purposely not translated into other languages? I have a bunch of strings
If you want to turn of the lint checking on missing translation, you may go
"Project Properties -> Android Lint Preferences -> Select MissingTranslation -> Swtich To Ignore In Severity",
hopes this helps others cause i just encounter this problem :)
There are 3 ways that I know of :
To apply the modification value by value : Set the attribute translatable="false"
on the <string>
definition:
<string name="account_setup_imap" translatable="false">IMAP</string>
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.
Another way I discovered while browsing Hackers Keyboard project sources:
You can add the prefix donottranslate-
to your resource file.
As in the previous example, lint will consider all of them non-translatable resources.
In your case, you can replace unlocalized-strings.xml
by donottranslate-strings.xml
.
It seems to work, but I haven't found any documentation for this tip.
See: Android Tools Project Site: Non-translatable Strings
Create a resource file with a file name starting with "donottranslate" (e.g. donottranslate.xml, donottranslate_urls.xml, etc), and lint will ignore its strings altogether when checking for missing translations.
Add to build.gradle
:
android {
lintOptions {
disable 'MissingTranslation'
}
}
I think that what you need instead of disabling lint is to mark them with attribute
translatable="false"
Another way to do that is add your string to gradle file, using resValue
or buildConfigField
. Something like that:
buildTypes {
debug {
buildConfigField "string", "app_name1", "App Name"
resValue "string", "app_name2", "App Name"
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "string", "app_name1", "App Name"
resValue "string", "app_name2", "App Name"
}
}
Usages:
// buildConfigField
BuildConfig.APP_NAME1
// resValue
getString(R.string.app_name2)