How to specify the path of localized Info.plist file - ios

I had to localize Privacy - Camera Usage Description key located in Info.plist. So what I did, is that I've localized it through the File Inspector. What happened is that Info.plist is moved to the Base.lproj. That is fine. Then, again inside of File Inspector, Localization section, I checked two more languages.
By doing this, additional Info.plist files are added into appropriate .lproj directories. So after I have added desired translations I run the project, but Xcode throw an error which says that path of Info.plist is wrong. That make sense because Info.plist is not at the same location anymore. So I've gone into Project Navigator, Build Settings section, and found a key that says Info.plist File and set its value to something like this:
MyProjectName/Base.lproj/Info.plist
Because the Info.plist file exists at that path, I was able to build/run an app, but still, it loads only the translation for the base language (english).
So, how should I specify the path of a localized Info.plist file ?

You should use an InfoPlist.string file. here is a related issue.
How to localise a string inside the iOS info.plist file?

Related

Xcode 10.0 OpenCV Cpp project does not read NSCameraDescription from info.plist

I have already added a info.plist file, but it just wont let me use the webcam.I am in a fix as I have already tried editing the info.plist as a source file. Correct me if I am missing something. Also linked the info.plist to the plist for the app in general settings. Am I missing something? Link the the error is given in the blue highlighted section
You need to set Privacy - Camera Usage Description in Info.plist, not NSCameraDescription.

How to localize NSLocationWhenInUseUsageDescription from Info.plist file in xamarin.iOS?

My application includes feature related to location tracking. I am trying to localize NSLocationWhenInUseUsageDescription string from Info.plist file.
As described in link below, I have added InfoPlist.strings file in en.Iproj and for localization InfoPlist.Stings file in de.Iproj. Added Localizations array (supported languages) in Info.Plist. Set "Localized resources can be mixed" to "Yes".
Xamarin.iOS localization of NSLocationWhenInUseUsageDescription.
Tested the app by changing language of device and simulator both. However, no success. It just displays default language message.
Please let me know what I am missing to add.

Build error after I localized Info.plist

I localized Info.plist :
And I got this build error :
error: could not read data from '/Users/cherif/Apps/Wesh/Info.plist':
The file “Info.plist” couldn’t be opened because there is no such file.
Actually there are now two Info.plist files :
fr.lproj/Info.plist
Base.lproj/Info.plist
How to localize the Info.plist path ?
Roll back those changes, add a InfoPlist.strings file to your project, localize it and then add the needed keys to it. For example:
"CFBundleDisplayName" = "App display name";
"CFBundleName" = "App bundle name";
To localized Info.plist :
Find in the x-code the folder Resources (is placed in root)
Select the folder Resources
Then press the main menu File->New->File...
Select in section "Resource" Strings File and press Next
Then in Save As field write InfoPlist ONLY ("I" capital and "P" capital)
Then press Create
Then select the file InfoPlist.strings that created in Resources folder and press in the right menu the button "Localize"
Then you Select the Project from the Project Navigator and select the The project from project list
In the info tab at the bottom you can as many as language you want (There is in section Localizations)
The language you can see in Resources Folder
To localize the values ("key") from info.plist file you can open with a text editor and get all the keys you want to localize
You write any key as the example in any InfoPlist.strings like the above example
"NSLocationAlwaysAndWhenInUseUsageDescription"="blabla";
"NSLocationAlwaysUsageDescription"="blabla2";
That's all work and you have localize your info.plist file!

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";
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"
Your plist file can have multiple versions for each language your application supports.
In Utilities \ File Inspector (on the right) click on "Localize":
And then choose the languages you want to have their own versions:
After that you will be able to enter each plist file and edit it as you want.
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.
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.";
As a matter of fact, my problem was that I had misspelled the NSLocationWhenInUseUsageDescription constant so of course it was not taken into account.
Sometimes you have to make a Clean first, Click Menu -> Product -> Clean.
In my case there was a conflict with other InfoPlist.strings file from another build target.
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
The file needs to be inside of a directory indicating the language, for example en.lproj
It depends on your iPhone or iPad ‘s language, it will automatically pick the description from the "InfoPlist.strings" file.

Localization of CFBundleDisplayName doesn't work on device

I tried to make the localization of the app name using CFBundleDisplayName.
I made the localized InfoPlist.strings according two different language.
In one strings file wrote:
CFBundleDisplayName="x11111"
and in another:
CFBundleDisplayName="y22222"
And in file info.plist, I added "Application requires iPhone environment" property, and set the boolean value to YES.
And in info.plist,the "Bundle display name" I used "x11111".
The localization worked ok on the simulator, but when tested on the device , it did not work.
On device, the name I used for 'Bundle display name' in info.plist can only be showed.
By the way, I use cocos2d for the project.
Anything I missed or did wrong?
If your localisation files were supplied to you, and you need to add them, be sure to add them correctly on per file basis. In Xcode, while you are adding files, pay attention how you add them. This is how they should look in Xcode Project Navigator.
I have added them by selecting all folders which didn't add them correctly to project.

Resources