NSBundleLocalizations preference does not return available most specific localization

I have a local location of "en" and "en-AU" (Australian English) for a specific file.

While the current locale is "en_AU", [[NSBundle mainBundle] localizations] creates the set of localizations that I expect:

 ( "en-AU", "en" ) 

However, [[NSBundle mainBundle] preferredLocalizations] (the one that really matters) produces only:

 ( "en" ) 

Why is the most specific supported localization completely excluded from the preferred list and instead returns a more general localization?

Is there a way to get an NSBundle to prioritize the most accurate localization available above the less specific options?

+4
source share
1 answer

I assume that this is because your phone is configured to use English rather than Australian English. I looked at the list of supported languages ​​on my phone and I could not find Australian English. Just English and British English, so probably why.

EDIT:

I think you should read this: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/LanguageDesignations.html#//apple_ref/doc/uid/20002144-BBCEGGFF

As I understand you, this is:

 NSLog(@"%@", [[NSLocale currentLocale] localeIdentifier]); 

prints en_AU and this is not the same as en-AU . If you read the related documentation, you already know the difference. For example, en-GB_AU means that British English speaks in Australia, which would be suitable for a British person in Australia.

Anyway, did you try to change en-AU to en_AU in your package?

0
source

Source: https://habr.com/ru/post/1402783/


All Articles