24

My app supports only 2 languages - English and German. So I have such folders structure for languages strings:

myproject/res/values/strings.xml

myproject/res/values-de/strings.xml

When I run Lint check I get many warnings about missing languages, that my app doesn't need to support:

"some_string" is not translated in af, am, ar, be, bg, ca, cs, da, el, en-rGB, es, es-rUS, et, fa, fi, fr, hi, hr, hu, in, it, iw, ja, ko, lt, lv, ms, nb, nl, pl, pt, pt-rPT, ro, ru, sk, sl, sr, sv, sw, th, tl, tr, uk, vi, zh-rCN, zh-rTW, zu

This warnings makes very difficult to understand which strings is not translated to German language. I have to look on each warning and search for "de" symbols to understand that this string doesn't have translation to German.

So my question is simple - how can I tell Lint to check only 2 languages?

Community
  • 1
  • 1
Paul Annekov
  • 3,193
  • 3
  • 19
  • 31
  • This can be helpful... http://stackoverflow.com/questions/11443996/lint-how-to-ignore-key-is-not-translated-in-language-errors – Santhosh Feb 15 '13 at 05:25
  • 1
    That link is only helpful if you don't care about ANY translations. One of my apps does lint correctly for 2 languages, the other (which uses the same languages and folder structure) throws up the error as seen above, I CAN ignore it, but I WANT to translate missing strings into my second language. I have to go line by line of more than 100 strings to make sure I'm not missing my target language, very frustrating. – thunsaker Feb 19 '13 at 21:00

3 Answers3

39

Update: You can limit the languages that are imported by Gradle! Cyril Mottier points out that you can specify which resources you support.

Starting Android Gradle Plugin 0.7, you can pass information about the configurations your application deals with to the build system. This is done thanks to the resConfig and resConfigs flavor and default config option. The DSL below prevents aapt from packaging resources that don’t match the app managed resources configurations:

defaultConfig {
    // ...
    resConfigs "en", "de", "fr", "it"
}

More info here Putting Your APKs on Diet and Android (search for resConfig on the page)


It appears that if you add a project to your build path, any and all languages that have been added to those projects will trickle down into your project. Such as the "google-play-services_lib" project, which added a good 40+ languages to my project that I "supported". This was the reason I got the crazy lint errors (similar to yours above), even though I only had a default and Spanish (values-es) resource folder.

The solution is to simply delete the resource files/folders that you are not supporting from the external/imported projects. After I deleted all but the values/values-es folder in the google-play-services_lib project, the lint warnings went away for the non-target languages. Be sure to keep a backup of the resource files in case you feel like adding support for those languages/regions at a later date.

Hope this helps. I was banging my head on the table and all over SO and Google for a few days trying to figure out how to phrase the problem. Then I finally realized what the difference was between my two projects that both had translations, the library projects.

I do wish there was a way to tell the project that I only support languages x/y/z and have it ignore the rest.

thunsaker
  • 854
  • 5
  • 11
  • The above only works if you add the Android Library Project to your workspace. If you are referencing Google Play Services library through gradle or maven, you get EVERYTHING that comes with it, since you cannot edit a packaged library. – thunsaker Jan 17 '14 at 16:34
  • @thunsakes, Your answer is not true. After adding resConfig to your build.gradle file, you just need to perform Build -> CleanProject. After that, unsuported locales will not be listed in lint "MissingTranslation" checks. – Simon-Droid Mar 09 '16 at 17:45
8

Same issue here.

I created a bug report, feel free to star it

http://code.google.com/p/android/issues/detail?id=50525

This happened since ADT 21.1 release.

I know no workaround for it (editing: I previously though to have found a workaround, but I looked at the wrong file, ups)

Daniele Segato
  • 12,314
  • 6
  • 62
  • 88
0

I have the same problem, due to the inclusion of the Google library service...

Here is my solution, for the moment:

  1. remove all the included libraries
  2. apply lint
  3. correct the errors
  4. add all the libraries again
AntoineP
  • 3,035
  • 1
  • 19
  • 22