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.
Created attachment 25311 [details]
The NSBundle.MainBundle.Localizations property lists duplicate entries.
I have the following entries in my Info.plist:
I have the following folders at the root of my project (previously under \Resources\ but I moved them to the root of my project to see if that was the issue):
If I remove the CFBundleDevelopmentRegion and CFBundleLocalizations data from Info.plist, I only get "en" as a extra entry in my NSBundle.MainBundle.Localizations property.
Thanks so much for taking the time to file this issue! :) I'm moving this over to the iOS team, as it looks like a bug there and not in the Visual Studio Tools for Xamarin. Thanks for your patience!
Please include your full build logs, crash reports (if any), test case (to reproduce) and all version information.
To get full build logs just set the log verbosity to diagnostic at the following locations:
- On Visual Studio for Mac: Preferences > Projects > Build
- On Visual Studio for Windows: Tools > Options > Projects and Solutions > Build and Run
On Visual Studio Windows you also want to add `-v -v -v -v` to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting `Properties`.
Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.
Easiest way to get exact version information:
- On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
- On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.
Then copy/paste the version information (you can use the "Copy Information" button).
I'm not sure what you mean exactly by: "The NSBundle.MainBundle.Localizations property lists duplicate entries" but it seems that the output of 'NSBundle.MainBundle.Localizations' after you removed 'CFBundleDevelopmentRegion' and 'CFBundleLocalizations' surprises you. You're getting "en" when you're probably expecting to get nothing.
The reason for this is because the 'CFBundleDevelopmentRegion' is automatically added if missing (you can check the generated Info.plist in your bin folder to confirm that).
Because of that 'NSBundle.MainBundle.Localizations' returns "en".
We're changing that behavior with https://github.com/xamarin/xamarin-macios/pull/2779 so we don't set 'CFBundleDevelopmentRegion' automatically.
Hope this answers your question, feel free to reopen the bug if you're still experiencing the issue.
Sorry, I haven't had the time to go over this and create an example.
Just check the attached screenshot. There are duplicate entries for my supported languages. If i debug the following line:
It says it contains 10 localizations, while I've only set that I support 5.
de - duplicate
nl - duplicate
no - duplicate
sv - duplicate
en - didn't add this.
If I remove the below information from my Info.plist:
The duplicates go away.
It's like it's reading the info from the Info.plist file and then appending the localization folders ontop of the information already in the Info.plist file.
Either base the metadata off of what is in the Info.plist file or the folder structure, not both.
So for the "en - didn't add this" as I explained we add this automatically but this is gonna change after https://github.com/xamarin/xamarin-macios/pull/2779.
As for the duplicates, unfortunately this is the behavior of the native method, it returns the language of the locales found in both the Info.plist and the localization folders (lproj).
I attached a native Swift project showing this.
It has an Info.plist with:
and 1 lproj for each language.
I then do: 'print (Bundle.main.localizations)', the equivalent of our 'NSBundle.MainBundle.Localizations' and it returns: '["en", "fr", "de", "it", "de", "it", "Base", "fr"]'.
Apple's documentation isn't very precise about the behavior of 'localizations': https://developer.apple.com/documentation/foundation/bundle/1417415-localizations.
"A list of all the localizations contained in the bundle." (all including duplicates I guess).
Xamarin.iOS is a thin layer on top of the native iOS frameworks and we cannot change the behavior of the native method. If you believe that this in not the way the API should behave you can still open a radar against Apple (https://developer.apple.com/bug-reporting) and hope that someone from Apple answer it (note: they are not very fast).
In the meantime I'm closing this bug as invalid as, unfortunately, we cannot fix it.
However I will make sure that we update our documentation: https://developer.xamarin.com/api/property/Foundation.NSBundle.Localizations
Created attachment 25877 [details]
Swift Example of Duplicated Locales