As per the documentation in Language and Locale there have been improvements to Resource-Resolution Strategy from Android 7.0(API level 24) which is easy to understand with the following table: Improved Resource-Resolution strategy
As per my requirements, I want my app's default langauge to be en_US. So, I am not providing separate resources for en_US. I also have en_GB resources present separately.
Now, as per the resolution strategy, if my device's language is en_US then the order in which it should look for resources is en_US -> en -> en_GB -> default which means for all locales of en, in my case en_GB will be picked up as I don't have 'en' resource separately, but the child 'en_GB' is present.
But, when I select my device language to be en_US, it correctly picks up the default language(en_US in my case) and not en_GB, which is exactly what I need in case the device language is en_US. When some other locale like en_IN or en_AU is selected, it picks up en_GB.
One way to solve this is that I provide en_US strings in 'en' and en_GB separately, which would lead to my desired behaviour. But, I am not able to understand why the default strings are being picked up when I select en_US as my device language.
Is it that en_US is the default language for android and whenever en_US is selected as device's language, it picks up the default strings if en_US is not provided separately?
I was having the same issue. After opening a bug report on Google Incorrect resource resolution strategy above Android N, defaulting to en_GB and not default strings.xml, they mentioned that this in the intended behaviour for Android N above. I'm quoting their reply here:
Starting in N, all English locales (except for US and US territories like Puerto Rico and American Samoa) fall back to some International English variant if such a locale is available.
So for en-CA, we would try these locales first, before falling back on en-GB (which is considered a representative of International English if there is no better International English locale): en-rCA (Canadian English), b+en+001 (International English), en (English). If you don't want en-GB strings to be picked up for en-CA, you should put resources in one of those three directories, as they would be considered a better match for en-CA.
So, it turns our en_UK
is considered "a representative of International English". The strings will fall back to "International English" or its representative before en
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With