} Avoid Android Lint complains about not-translated string

} }

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 that are common for all the languages and need no translation, so I've created an unlocalized-strings.xml file within values directory.. Running Android Lint to check for problems it keeps saying that some translations are missing.. I do not want to disable this check on the whole project, I'd like to disable it only in some XML files.. is it possible?

"title_widget_updater_service" is not translated in de, en, en-rUS, it


Issue: Checks for incomplete translations where not all strings are translated
Id: MissingTranslation


If an application has more than one locale, then all the strings declared in one language
should also be translated in all other languages.


By default this detector allows regions of a language to just provide a subset of the
strings and fall back to the standard language strings. You can require all regions to
provide a full translation by setting the environment variable
ANDROID_LINT_COMPLETE_REGIONS.
prev() { var u = this._chars.toUpperCase(); console.log("u "+u)

How can defined this region of unlocalized strings?

67732 次浏览
var l = u.slice(-1).charCodeAt(0);

I think that what you need instead of disabling lint is to mark them with attribute

translatable="false"
var z = this._nextLetter(l);

I don't know how to ignore all the file, but you can do it string by string using:

<string name="hello" translatable="false">hello</string>
var rl = u.slice(1)

It's the ignore attribute of the tools namespace in your strings file, as follows:

<?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>
var y = (rl == "A") ? "Z" :this._prevLetter(rl.charCodeAt(0))

If you want to turn of the lint checking on missing translation, you may go

var txt = '';

"Project Properties -> Android Lint Preferences -> Select MissingTranslation -> Swtich To Ignore In Severity",

var i = u.length;

hopes this helps others cause i just encounter this problem :)

var j = this._chars

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>
var change = false

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.

while (i--) { if(change){

Another way I discovered while browsing Hackers Keyboard project sources:
if (u[u.length-1] == "A"){ txt += this._prevLetter(u[i].charCodeAt(0)) }else{ txt += u[i] You can add the prefix donottranslate- to your resource file. } As in the previous example, lint will consider all of them non-translatable resources.
}else{ In your case, you can replace unlocalized-strings.xml by donottranslate-strings.xml. if (u[u.length-1] == "A"){ txt += this._prevLetter(u[i].charCodeAt(0)) It seems to work, but I haven't found any documentation for this tip.

change = true }else{ change = true txt += this._prevLetter(u[i].charCodeAt(0))

See: Android Tools Project Site: Non-translatable Strings

}

And here is a Android Studio solution for disabling this fatal Lint error:

enter image description here

}

To avoid warnings in Android Studio, open Preferences ==> Inspections, uncheck "Incomplete translations". But it won't affect Gradle build.

} if(u == "A" && txt == "Z"){ this._chars = '' }else{

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.

this._chars = this._reverseString(txt);

Add to build.gradle:

android {
lintOptions {
disable 'MissingTranslation'
}
}
}

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"
}
}
console.log(this._chars)

Usages:

// buildConfigField
BuildConfig.APP_NAME1


// resValue
getString(R.string.app_name2)
return (j);

There is also the "Translation editor" (right click on string.xml "Open Translation Editor").

Then check the 'Untranslatable' box on a string.

https://developer.android.com/studio/write/translations-editor