Monday 26 October 2020

Android does not pick up strings.xml from Any Region (for ex.values_zh) specifically for locale zh_US

I have 2 module projects (lets say App1 and App2) into the same repo, both apps have values_zh, values-zh-rTW and values-zh-rHK in their respective src>res folders.

When I set a custom locale of the device to zh_US (on rooted device/emulator) then the App1 picks up string.xml from values_zh but App2 is picking from values-zh-rTW instead of values-zh.

But if I add values-zh-rUS to App2 then it pick it from there. I wanted it to pick up from values-zh (Since US can fall in to Any Region).

Note : if I set the custom locale to zh_CA then both App1 and App2 picks up string.xml from values-zh (Any region). Why is this specific problem for zh_US and the differences in 2 apps (Trying to understand if any code is responsible for it. I guess Android system should pick the correct strings.xml as per my understanding. Need clarification). Any Idea, please suggest. TIA.

I have already gone through below Android documentation but did not find explanation for above. https://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch https://developer.android.com/guide/topics/resources/providing-resources.html https://developer.android.com/reference/java/util/Locale.html



from Android does not pick up strings.xml from Any Region (for ex.values_zh) specifically for locale zh_US

No comments:

Post a Comment