17

I need to localize two keys of info.plist: NSLocationUsageDescription and NSCameraUsageDescription. So I tried to create a new file called InfoPlist.strings and then I localized it, but app always shows strings stored in info.plist file. What's wrong?

Official documentation from Information Property List Key Reference

Localized values are not stored in the Info.plist file itself. Instead, you store the values for a particular localization in a strings file with the name InfoPlist.strings. You place this file in the same language-specific project directory that you use to store other resources for the same localization. The contents of the InfoPlist.strings file are the individual keys you want localized and the appropriately translated value. The routines that look up key values in the Info.plist file take the user’s language preferences into account and return the localized version of the key (from the appropriate InfoPlist.strings file) when one exists. If a localized version of a key does not exist, the routines return the value stored in the Info.plist file.

My InfoPlist.strings file:

NSCameraUsageDescription = "hello";
NSLocationUsageDescription = "hello hello";
DrKey
  • 3,365
  • 2
  • 29
  • 46
  • Did you change the language of iPhone simulator? Change from the Settings app, not from the scheme. – scottphc Aug 27 '16 at 18:16
  • Use InfoPlist.strings http://stackoverflow.com/questions/25736700/how-to-localise-a-string-inside-the-ios-info-plist-file – onmyway133 Mar 07 '17 at 14:52

10 Answers10

15

Please check in the generated application package, whether the file is really stored in there and it is put to the correct location. Usually this is the missing step.

Just go into the project settings, open "Build Phases" and see whether the file can be found in "Copy Bundle Resources"

Stefan Eilers
  • 161
  • 1
  • 3
  • 1
    Good point! For me InfoPlist.string was ignored until I manually added it to Copy Bundle Resources – cyanide Feb 26 '18 at 00:07
7

Your plist file can have multiple versions for each language your application supports. In Utilities \ File Inspector (on the right) click on "Localize":

enter image description here

And then choose the languages you want to have their own versions:

enter image description here

After that you will be able to enter each plist file and edit it as you want.

yonivav
  • 994
  • 11
  • 18
  • ok, I have file named "someinfo.plist" which works as "info.plist" but need to be specified in project settings (section "Packaging"). How to specify a path to it when it is localized? – Vyachaslav Gerchicov Oct 27 '16 at 15:12
  • 1
    It's automatically. for each language youe app will use the relevant plist. if there isn't one (there isn't a plist file for current language) - your app will use the basic one. – yonivav Oct 31 '16 at 14:39
7

InfoPlist.strings doesn't consider your scheme's Application Region, but the region set in the device! On your device: Settings-> General -> Language & Region, check if iPhone Language is the one that you like.

grrigore
  • 1,050
  • 1
  • 21
  • 39
Laura Corssac
  • 1,217
  • 1
  • 13
  • 23
3

Since iOS 10, you are required to add the privacy keys to your Info.plist.

<key>NSPhotoLibraryUsageDescription</key>
<string>Please allow access to the photo library.</string>

Of course, you still need those keys to be localized (and you can't localize the application's Info.plist). So you ALSO add those privacy keys to the InfoPlist.strings, which in turn are localized.

"NSPhotoLibraryUsageDescription" = "Please allow access to the photo library.";
Cezar Signori
  • 586
  • 6
  • 13
2

As a matter of fact, my problem was that I had misspelled the NSLocationWhenInUseUsageDescription constant so of course it was not taken into account.

Sebastien
  • 3,583
  • 4
  • 43
  • 82
  • haha, just wanted to comment the same: had a typo in a word, check the word letter by letter – Async- Mar 16 '21 at 12:27
0

Sometimes you have to make a Clean first, Click Menu -> Product -> Clean.

Sometimes you have to make a Clean first

rockXrock
  • 3,403
  • 1
  • 25
  • 18
0

In my case there was a conflict with other InfoPlist.strings file from another build target.

Victor Do
  • 2,237
  • 1
  • 13
  • 9
0

After double checking everything said in this thread, my last action was deleting the app and its' data then re-run/re-install it to Simulator and my localization worked for Info.plist

One more thing, I made the simulator main language the testing language I want (Arabic), and to change that in the simulator Settings>General>Language

Omar N Shamali
  • 503
  • 5
  • 11
-1

The file needs to be inside of a directory indicating the language, for example en.lproj

Dustin
  • 1,030
  • 11
  • 15
-2

It depends on your iPhone or iPad ‘s language, it will automatically pick the description from the "InfoPlist.strings" file.

OguzzYlcn
  • 59
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 22 '21 at 18:12