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.
Related
App Store Connect keeps blocking App upload by issuing
ITMS-90129: The bundle uses a bundle name or display name that is already taken.
So far I tried:
Changing the Display Name, Bundle Identifier (even with generated Hashcodes to make sure that the names really are not taken already)
Created alternative Profiles, Identifier and App in App Store Connect (also using the same mentioned hashcode)
Tried these changes in the Xcode input fields (under 'General') and also directly modifiyng the Info.Plist
Re-Exporting the project from Unity to XCode with the new naming (to make sure Unity is not writing some bundle id somewhere which is not visible in XCode)
(Update) Tried to Clean the build folder based on
minchaej suggestion
Additional information: The XCode project is exported from Unity and we're using Firebase which is installed via Pods.
I'm grateful for any hint where to continue looking - because I'm really running out of ideas. Thanks a lot for taking the time.
Cheers
vik
The solution for this (probably very Unity-to-XCode specific) issue was localization related:
I had to remove all but the English localization entry in the Localization section.
I'm not sure why there were other loca resources before (since we didn't set them up) but I assume these included an alternative app name which was causing the ITMS-90129 to pop up.
My salvation for ITMS-90129 is the next:
Remove definitions for
CFBundleName
CFBundleDisplayName
CFBundleSpokenName
for base(en) localisation InfoPlist.strings.
Setup this variables with single value $(PRODUCT_NAME) directly in Info.plist
Variable $(PRODUCT_NAME) define via root project Build Settings/Packaging/Product Name
Setup variable LSHasLocalizedDisplayName in YES value in Info.plist
Setup Russian (or other) localisation for variables
CFBundleName
CFBundleDisplayName
CFBundleSpokenName
via InfoPlist.strings
As I am personally assume, setup this variables via base localisation is the key of problems in which I am faced with
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?
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.
I am implementing localization function for my app, and everything works fine except the app display name under the icon. My info.Plist is as:
I tried to remove the Bundle display nmae and bundle name and it also did not work.
My localization string file is like:
Anyone can help me with this? I have no idea what I did wrong, thank you.
To localize the app name you should create a InfoPlist.Strings file as apple explains here in "Localizing the Information Property List Files" section. Then you just need to define the keys CFBundleDisplayName and CFBundleName as you already are doing.
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.