porlicus
porlicus

Reputation: 871

After upgrading Android Studio to version 3.2 i got errors on localization

I have string resources:

Everything was OK till I updated Android Studio to the latest version 3.2. Now lint gives me tons of errors regarding default string resource file (values\strings.xml):

".... is not translated in "en" (English)"

What is the best solution? I don't want to create another folder values-en which would contain just a copy of my default values\strings.xml resource...

Upvotes: 3

Views: 552

Answers (3)

porlicus
porlicus

Reputation: 871

One of the solutions is to include "resConfigs" section in build.gradle file as described here https://developer.android.com/studio/build/shrink-code to keep only the languages that my app officially supports. After that there were no more errors.

For me it will be:

android {
    defaultConfig {
        ...
        resConfigs "de"
    }
}

I like this solution because I don't want to completely disable "MissingTranslation" feature.

Upvotes: 1

Hashem Jahangiri
Hashem Jahangiri

Reputation: 157

In the lint version, 3.2 new features added. for more information about these features you can visit this reference: http://tools.android.com/tips/lint-checks

MissingTranslation
------------------
Summary: Incomplete translation

Priority: 8 / 10
Severity: Error
Category: Correctness:Messages

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

If the string should not be translated, you can add the attribute
translatable="false" on the <string> element, or you can define all your
non-translatable strings in a resource file called donottranslate.xml. Or, you
can ignore the issue with a tools:ignore="MissingTranslation" attribute.

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
<resources> element in your resource file. (The tools prefix refers to the
namespace declaration http://schemas.android.com/tools.)

According to this section of the article, you can use these methods:

  1.
  <resources
  xmlns:tools="http://schemas.android.com/tools"
  tools:ignore="MissingTranslation">
  ...
  </resources>


  2.
  <string name="any_name" translatable="false">anything</string>

Upvotes: 5

Chirag Savsani
Chirag Savsani

Reputation: 6140

You have to add disable 'MissingTranslation' in app level gradle.

android {
     defaultConfig {
           //Your config
     }

     lintOptions {
       disable 'MissingTranslation'
   }
}

Upvotes: 0

Related Questions