Search code examples
androidlocalizationlocaledrawableandroid-resources

Android drawable is picked from drawable-en-rCA when locale is en_IN


I have an image in folder drawable-en-rCA. I do not have any folder like drawable-en-rIN, or drawable-in. When I change my app locale to en_IN, drawable is picked-up from drawable-en-rCA whereas it is expected to take from default drawable folder as there are no drawables present specific for en_IN.

Can somebody help me to understand why this is happening?


Solution

  • If you are experiencing this issue on device running Android N or above, I think your issue might be related to the findings mentioned on this answer: Localization for Canada defaults to UK; should default to US. Google released a documentation on the Improvements to Resource-Resolution Strategy post Android N. There was also a bug report Incorrect resource resolution strategy above Android N, defaulting to en_GB and not default strings.xml for the issue but it turns out it is not a bug but a feature. Here is their response:

    Starting in Android 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.

    For your case, based on these (specially the new Resource-Resolution Strategy document), it seems that when you select en_IN, if any resource is not present in drawable-en-rIN, then it looks for the closest international english directory, which in your case in drawable-en-rCA. If its not present there, only then it default to the default drawable folder.

    Hope it helps.