Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't localize info.plist strings

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";
like image 543
DrKey Avatar asked Feb 12 '14 18:02

DrKey


People also ask

How do you localize a string inside the iOS Info plist file?

To do this, go to File->New->File , choose Strings File under Resource tab of iOS , name it InfoPlist , and create.

How do you localize a string in Swift?

Select the project and under “Localizations”, click the “+” icon. Add any language you want (I selected Italian) then click on “Finish”. Now go back to Localizable. string file, select it and on the File Inspector (right menu) select “Localize”.

What is localizable string?

A localized string can have different values depending on the language in which the project is being build. There are two categories of localized strings: the strings included in the installation package's UI, common to every MSI file.


2 Answers

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"

like image 158
Stefan Eilers Avatar answered Sep 21 '22 23:09

Stefan Eilers


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.

like image 37
yonivav Avatar answered Sep 22 '22 23:09

yonivav