Application fails to read strings from localized folders

主宰稳场 提交于 2019-12-25 09:27:23

问题


I got a strange case going on. My app has 4 language supports: English, Turkish, Russian & Ukrainian. I got the following resource folders:

I got Turkish translation on values, so default will be Turkish if it fails to find the translation of any string.

Below you can see there are no keys needing translation:

Okay so, as far as I know, when I change the phone language, it should use corresponding strings.

When I make phone language Turkish:

Great. Now, English:

Works too. Now Russian:

Ugh.

So Turkish and English are working, but making phone language Russian or Ukrainian does not.

There is no manual setting for locale anywhere in the app. When I call

getResources().getConfiguration().locale

or

getResources().getConfiguration().getLocales()

I get correct locale, "ru_RU".

Is there something I'm missing here ? What might cause this problem ?


回答1:


I found the problem, it was resConfigs in build.gradle. My config was

resConfigs "en", "tr"

so it was not compiling ru & uk resources. Adding "ru" & "uk" solved the problem. Final line looks like this:

resConfigs "en", "tr", "ru", "uk"


来源:https://stackoverflow.com/questions/42361243/application-fails-to-read-strings-from-localized-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!