3

Is there a way to localise the NSLocationWhenInUseUsageDescription in Info.plist in the Xamarin Studio? Or any possibility to localise the complete Info.plist would be a solution as well.

I tried the following steps as it looks analogue to the How to localise a string inside the iOS info.plist file? but it does not work for me.

So these are the steps:
In both en.proj and de.proj:
I added an empty file InfoPlist.strings

In Info.plist:
I have set the key of the "NSLocationWhenInUseUsageDescription" to "NSLocationWhenInUseUsageDescriptionMessage".

In InfoPlist.strings:
I added the "NSLocationWhenInUseUsageDescriptionMessage" as key in the strings files and the corresponding transitions in each, but it seems not to work -> the raw string "NSLocationWhenInUseUsageDescriptionMessage" is shown when the user is asked for the permission.

Community
  • 1
  • 1
n.t
  • 103
  • 2
  • 10

2 Answers2

2

I had similar problem (only I used "Always" instead of "WhenInUse". Here's what worked:

In both en.lproj and de.lproj add the file InfoPlist.strings. Each of the files contains only one line:

"NSLocationAlwaysUsageDescription" = "Your location needed, because...";

In Info.plist, the string doesn't matter anymore, because it will be taken from the InfoPlist.string file. The relevant lines in Info.plist look like this:

<key>NSLocationAlwaysUsageDescription</key>
<string>No text needed here.</string>

Maybe you forgot the semicolon in the strings-files? Or your two folders were named *.proj instead of *.lproj?

Oliver Eichhorn
  • 307
  • 2
  • 6
  • Thank you for the suggestion. I will try it as soon as start working on the iOS8 version of the app. For the time being I stopped working on the iOS8 version as there are a lot of iOS7 devices out there and this string is not needed on iOS7. – n.t Nov 28 '14 at 14:04
  • This doesn't seem to work in my case. When the user is prompted with the NSLocationWhenInUseUsageDescription message, the one in Info.plist is shown (In your example : "No text needed here." would be shown). I have added these files : Resources\en.lproj\InfoPlist.strings (and fr.lproj in my case) with the following as a test : "NSLocationWhenInUseUsageDescription"="bbbb"; – Frank Nov 02 '16 at 17:53
1

We faced a similar issue for the localization of NSLocationWhenInUseUsageDescription. The translation was shown on the iOS simulator but never on real devices. After we fixed our CFBundleLocalizations array from upper case language codes to lower case in the Info.plist the permission description was translated correctly for all languages.

Not correct:

<key>CFBundleLocalizations</key>
<array>
    <string>EN</string>
    <string>DE</string>
    <string>BG</string>
    <string>PL</string>
    <string>FR</string>
    <string>CS</string>
</array>

Correct:

<key>CFBundleLocalizations</key>
<array>
    <string>en</string>
    <string>de</string>
    <string>bg</string>
    <string>pl</string>
    <string>fr</string>
    <string>cs</string>
</array>
Christopher Stephan
  • 1,081
  • 16
  • 33