Bug 57968 - InfoPlist.strings does not recognize all keys => NSLocationUsageDescription is ignored
Summary: InfoPlist.strings does not recognize all keys => NSLocationUsageDescription i...
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 10.10 (d15-2)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-07-06 09:00 UTC by José Fabio Martinez Gonzalez
Modified: 2017-09-13 12:06 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description José Fabio Martinez Gonzalez 2017-07-06 09:00:07 UTC
In my iOS app I need to localize the descriptions for the iOS alerts that appear when the user is asked for a certain right, like to use the camera or for location. The usual way to do this is to create a xx.lproj folder inside the Resources folder (where xx is the language, e. g. German is de.lproj). Inside that folder you create an InfoPlist.strings file which is a simple key value file for properties from the Info.plist file.

However, it did not work for me. I thought I did something wrong so I reread the Xamarin tutorial about iOS localisations and found the following detail here: https://developer.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization/#App_name

Valid keys are only:
• CFBundleDisplayName
• CFBundleName
• CFBundleShortVersionString
• NSHumanReadableCopyright

Keys I need to translate are:
• NSLocationAlwaysUsageDescription
• NSLocationUsageDescription
• NSCameraUsageDescription
• NSPhotoLibraryUsageDescription

This is an example of my InfoPlist.strings file for German translations located in my iOS project in Resources/de.lproj/InfoPlist.strings:

"NSLocationAlwaysUsageDescription" = "Wir brauchen deinen Standort um ihn deinen Kollegen auf der Karte zu zeigen. Wir nutzen deine Position ausschließlich für diesen Service.";
"NSLocationUsageDescription" = "Wir brauchen deinen Standort um deinen Kollegen deine Position auf der Karte zu zeigen. Wir nutzen deine Position ausschließlich für diesen Service.";
"NSCameraUsageDescription" = "Wir möchten gerne auf deine Kamera zugreifen, so dass du Fotos von Personen, der Farm, Maschinen und Ortsmarken machen kannst.";
"NSPhotoLibraryUsageDescription" = "Wir möchten gerne auf deine Fotogalerie zugreifen, so dass du Fotos von Personen, der Farm, Maschinen und Ortsmarken auswählen kannst.";

Nothing works, except the valid keys I listed above.
Comment 1 José Fabio Martinez Gonzalez 2017-07-06 09:27:57 UTC
Sorry I need to update this bug. I tested very quick and thought all keys are not working. But the only key that does not work is NSLocationUsageDescription. For all other keys I get the right translation.
Comment 2 Timothy Risi 2017-07-06 17:23:03 UTC
Hello Jose,

According to https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html NSLocationUsageDescription is no longer used as of iOS 8.  It says to use NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription instead.  Can you try whichever of those would apply in your case and update whether it works?
Comment 3 José Fabio Martinez Gonzalez 2017-07-07 08:07:23 UTC
Hi Timothy,

you were absolutely right. Sorry my fault for not reading the documentation carefully. This bug can be closed.
Comment 4 Eric Kinoshita 2017-09-12 21:00:53 UTC

I'm facing this issue with `NSLocationAlwaysUsageDescription` key. I added the `CFBundleDisplayName` keys and values for test purposes and they worked fine, the issue seems to be with the location usage description specifically.

I'm using Xamarin Forms, the app is targeted for iOS 8 and the localization files (for iOS specific stuff) structure is as follows:

* iosProject/Resources/Base.lproj/InfoPlist.strings
* iosProject/Resources/pt_BR.lproj/InfoPlist.strings

When the authorization dialog appears, it displays the content defined in Base.lproj/InfoPlist.strings. The app name is displayed correctly, fetched from pt_BR.lproj

Jose, did you do something special in your quick test? Because I already tried many different things with no success.
Comment 5 José Fabio Martinez Gonzalez 2017-09-13 12:06:08 UTC
@Eric You don't need the Base.lproj as far as I know. Just define the text for your default language in the Info.plist file. Additionally, please ask this question on StackOverflow or in the Xamarin forums because I don't think that this is a bug that needs to be reported. This issue here is already resolved