15

I've completed translating my app to Turkish using Base Localization. However, I also need to translate NSLocationWhenInUseUsageDescription key in my Info.plist file. I did exactly what I did for everything else:

Went to File inspector and checked Turkish:

enter image description here

Then I went to the new strings resource and completed my translation by adding this key to the localization file:

enter image description here

"NSLocationWhenInUseUsageDescription" = "[my Turkish description of location permissions]";

Saved, compiled, even deleted app from device and rebuilt, but no avail. When my app asks for location permissions, the explanation underneath is still the English one (I've tried including the English translation as well under Base translation file, but it didn't change anything).

Everything else is Turkish, translated just fine. It's just the location permission that doesn't translate. I've also seen How to localise a string inside the iOS info.plist file? and added the "Localized resources can be mixed" = YES key (of course, as CFBundleAllowMixedLocalizations, not literally that sentence) to my original plist but that also didn't change anything.

How can I solve the problem?

Community
  • 1
  • 1
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389

3 Answers3

22

Here's what ended up working for me in Xcode 7.1.

First, go to project directory and manually create two InfoPlist.strings files, the first inside the en.lproj folder and the second inside the fr.lproj folder.

Both files should have the following content :

NSLocationWhenInUseUsageDescription = "YOUR TEXT HERE";

Since the files won't show up automatically in Xcode, you have to manually add both to the project bundle, this can be achieve via right-clicking the project name in Xcode and choosing the Add files to X option, then selecting the files you just created.


Also if you want to test the result & make sure things work, changing the Application Language in Edit Scheme > Run > Options isn't enough.

You need to change the simulator or the device language via Settings > General > Language & Region > iPhone Language

Zack Braksa
  • 1,628
  • 18
  • 26
  • Doesn't Xcode automatically create the appropriate files/folders when you turn on localization from inspector? Or are you saying that there's a bug with Xcode's tracking (changes/deletion/creation etc) that way? – Can Poyrazoğlu Nov 01 '15 at 20:15
  • 2
    I tried localizing the `Info.plist` by using the localization button in the inspector menu but didn't work for me, even after cleaning and removing and re-trying multiple times. – Zack Braksa Nov 01 '15 at 21:46
  • 1
    There is definitely a bug somwhere with the localization process, nice to see you haven't encountered it when creating files/folders manually. Will try that. – Can Poyrazoğlu Nov 01 '15 at 21:55
  • 1
    Yep, and in Xcode 7, I couldn't even use the localize `Info.plist` button in the Inspector because Xcode kept crashing everytime I touched it. Thankfully Xcode 7.1 fixed the crashing but I guess not the whole process. – Zack Braksa Nov 02 '15 at 01:15
  • Nearly 2 hours I am trying to understand why its not working for me. Did not realise I had to change the actual phone language as well. Thought I can just change the Application language like with NSLocalizedString. Thanks – crashoverride777 Feb 11 '17 at 20:05
  • This worked for me in xcode10.1 but the fallback language I want is always English but here in this case, it is the previously used language. can anyone suggest how to do that? Also I am unable to find localization button in Inspector, is it removed in xcode10.1?? – Muhammad Awais Sep 17 '19 at 07:11
  • I created and added a InfoPlist.strings file for French into my project and I loaded it with: "NSContactsUsageDescription" = "Je confirme que je souhaite autoriser $(PRODUCT_NAME) pour accéder à mon fichier de contacts."; Then I changed my device to use the French language. Then I ran my app on that device via XCode and when I asked, in my app, to access Contacts for the first time, I got the expected French translation. Ran XCode 11.5 and the device was a iPhone SE, 2nd Generation. Note that I did not have to edit my scheme to use French to get this result. – Gallymon Jul 29 '20 at 00:37
3

I've started over. Removed the translations, cleaned the project, and tried again. It worked. I have no idea why it didn't initially though.

Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
  • @Zak well because of the indeterministic nature of the problem I can't tell something exact, but if you want to be on the safe side, resetting the simulator before trying these won't hurt :) – Can Poyrazoğlu Oct 29 '15 at 10:47
  • I had the exact same problem. Bluetooth permission requests were translated, location not. This solved the issue. – Maël Pedretti May 12 '22 at 08:21
0

My problem seems to be case sensitive:

My InfoPlist.strings had a lower "i" in finder and Xcode (infoPlist), but needs to be upper.

I changed file name and reference in the source Xcode Project and it works (or deleted and re-create with the right name).

Forge
  • 6,538
  • 6
  • 44
  • 64
DonMizzi
  • 566
  • 1
  • 6
  • 17