Android 7.0 Nougat picks up default strings when device language is en_US
Asked Answered
C

1

7

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?

Cloison answered 1/12, 2016 at 9:11 Comment(2)
It seems to be still happening. I thought it is specific to en_CA. It seems like a platform bug. Did you by any chance open a bug with Android? See our discussion here: Localization for Canada defaults to UK; should default to USVorster
I've created a bug report here: issuetracker.google.com/issues/64429534. Feel free to suggest changes to improve it, or comment / star it so that it could be looked at. Thanks.Vorster
V
3

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.

Vorster answered 16/8, 2017 at 9:32 Comment(1)
Oh, I spent so much time before I found this post ( The same not for English only, but for Spanish as well. #61545179Talkfest

© 2022 - 2024 — McMap. All rights reserved.