Android Lint: how to ignore missing translation warnings in a regional locale string file that purposely only overrides some default translations?

前端 未结 6 853
南方客
南方客 2020-12-24 11:34

Is it possible to translate some strings, but not all, in a separate resource file without Lint complaining about MissingTranslation?

For example: m

6条回答
  •  猫巷女王i
    2020-12-24 11:48

    Lint supports partial regional translations, but needs to know what language the default strings are. That way, it can distinguish a partial regional translation from missing translations in a different locale.

    To specify the locale in values/strings.xml:

    
    

    Quote from the lint command-line tool, when running lint --show:

    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 tell lint (and other tools) which language is the default language
    in your res/values/ folder by specifying tools:locale="languageCode" for
    the root  element in your resource file. (The tools prefix
    refers to the namespace declaration http://schemas.android.com/tools.)
    

    Source: https://android.googlesource.com/platform/tools/base/+/master/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/TranslationDetector.java#88

    Add the locale specification to your default language file, and you shouldn't get that error for en-rUS, but will still be informed of any other missing translations.

提交回复
热议问题