Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I'm trying to set up the CultureInfo of my Resouce file to archive localization but the class Foundation.NSLocale.PreferredLanguages is returning the value 'pt' instead of 'pt-BR' while runing this sample on iOS simulator;
Using Visual Studio 2015 RC +
Windows 10 Build 10162 +
Follow the sample to reproduce the issue:
Steps to reproduce:
1 - Open the iOS simulator (iphone 4 for example)
2 - Before running the application go to settings-> General-> Language & Region-> iPhone Language
and change it to 'Português (Brasil)'. Hit "done" and then "Change to Portuguese (Brazil)" option.
3 - Set a breakpoint on line 20 of file Xamarin.Localize.pt_BR.Bug.iOS.Localize and check the value returned.
it was supposed to be 'pt-BR' not just 'pt';
4 - Run the application on iOS simulator a see the issue;
Just find out that NSLocale.AutoUpdatingCurrentLocale.LocaleIdentifier is correctly returning the value 'pt_BR' on iOS.
Maybe it is more useful to update de xamaring documentation regarding to iOS Localization (http://developer.xamarin.com/guides/cross-platform/xamarin-forms/localization/) to use NSLocale.AutoUpdatingCurrentLocale.LocaleIdentifier instead of NSLocale.PreferredLanguages 
Our bindings are just a thin wrapper around the iOS API, which means that if NSLocale.PreferredLanguages do not return the value you expect, you'll have to ask in Apple forums / file bugs with Apple about it.
That said, I believe NSLocate.PreferredLanguages returns the *language*, not the *locale* (i.e. in Brazil Portuguese the language), while NSLocale.AutoUpdatingCurrentLocale returns the *locale* (which is what you want).
I'll send a note to the documentation team to check if it makes sense to update the docs.
Locale is different (number formatting, etc) and can be set independent of language.
Regarding this feedback:
>it was supposed to be 'pt-BR' not just 'pt';
From Apple's doc
it says "For example, use pt as the language ID for Portuguese as it is used in Brazil and pt-PT as the language ID for Portuguese as it is used in Portugal"
I cannot explain _why_ Apple has implemented it this way, but NSLocate.PreferredLanguages is definitely the correct property to check... and for some reason, they use "pt" for Brazil and "pt-PT" for Portugal.
I have updated the Xamarin.Forms sample
to properly display Portuguese (in Brazil and Portugal). The iOS.Localize class now contains this code
if (pref == "pt")
pref = "pt-BR"; // get the correct Brazilian language strings from the PCL RESX (note the local iOS folder is still "pt")
pref = "pt-PT"; // Portugal
and the Resources folders are named correctly so that iOS loads the images and strings files for Brazil and Portugal.
Thank you guys.