n.t
n.t

Reputation: 103

Xamarin.iOS localization of NSLocationWhenInUseUsageDescription

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.

Upvotes: 3

Views: 4067

Answers (2)

Christopher Stephan
Christopher Stephan

Reputation: 1141

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>

Upvotes: 1

Oliver Eichhorn
Oliver Eichhorn

Reputation: 307

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?

Upvotes: 2

Related Questions