iOS localization is broken with the upgrade iOs 9 + Xcode 7 - ios

I localized my app in Italian and English, using the Localizable.strings file and the NSLocalizedString macro. I also enabled base localization. Everything works fine in the simulator and on devices with iOS 8, but on iOS 9 the app is always in english, even on devices with the italian language selected as default in the iPhone settings.
Does iOS 9 changes something with localization?
Here's a screenshot of the Xcode localization settings
1
And of the device used for testing
Thanks in advance

Solved, the "problem" was the key "Localization native development region" in the info.plist file. It was setted to Italy, so when the app was running in a device with the Italian language as default it was showing the Base localization version of the strings (the English version).
Changing the value to United States solved the issue.

I have another solution, just remove the key 'Localizations' in info.plist.
It works for my case.

I've found a workaround.
The root cause of this problem is Apple changed the "Language Identifiers" in iOS 9, please refer this.
Since NSLocalizedString() (and variants thereof) access the "AppleLanguages" key in NSUserDefaults to determine what the user's settings for preferred languages are. I forced NSLocalizedString to use a specific language with is noted as their old Language Identifiers in older iOS versions once I found their Language ID is in new format. In another word, I made a mapping of "AppleLanguages" key value.
To do this, please refer to: How to force NSLocalizedString to use a specific language
I think Apple did a very bad job in compatibility!!

Related

Googlecast labels not localized to device's language

According to Googlecast's release notes and this issue tracker, localization should already be supported/implemented by default when using the new 4.4.2 SDK. Checking the actual GoogleCastUIResources.bundle also confirms the new translations. However for my iOS applications, changing the device language to any other languages still gives me the strings in English.
Am I missing any intermediate steps to get localization for my iOS apps?
Add the language in your project file, that worked for me.

ios InfoPlist.strings translations doesn't work but all other i18n files work fine

I'm currently experiencing an issue where translations in the InfoPlist.strings file are completely ignored by the Simulator but at the same time it picks up on all other i18n related files which work fine and the "error" only occurs when the app asks for a given permission from the user.
The following keys are being translated:
NSCameraUsageDescription
NSContactsUsageDescription
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
NSPhotoLibraryUsageDescription
But the value that is always returned is that of the default InfoPlist.strings.
I've verified that the files are properly installed, Xcode isn't detecting any problems with them and shows all the available localizations for the app.
Has anyone had this happen before?
Currently happening with Xcode 8.2.1 on all supported iOS versions.
For anyone else running into this sort of issue, the reason why the UI Notifications weren't being translated is because the simulator REQUIRES for the OS language to be set to the given location.
This means that to properly test that the application is being internationalized, setting the schema to use the given language isn't enough if you're internationalizing say the Notification Permissions text, you must go to Settings > General > Language & Region > iPhone language and set the language to test, only them will you be able to test OS level translations.
Hopes this helps someone.

Can I change the Apple Watch simulator language?

Is it possible to change the Apple Watch simulator locale? I want to test the localization of my watch app. I can change language on an iPhone simulator, but the watch simulator is always in English. I can't find any language settings:
Most certainly not possible neither via Watch Simulator UI nor iOS Simulator Watch app, but you can copy over values from iOS Simulator folder located in:
<simulator_dev_folder>/data/Library/Preferences/.GlobalPreferences.plist
to the same file in your Watch Simulator.
Plist keys to look for:
AppleLocale
AppleLanguages
AppleKeyboards
You cannot change the Apple Watch simulator locale, but you can change the locale of your Watch App. I use this to test localization. To change your app locale, go edit the Watch App Scheme: Run->Options->Application Language - choose the language and re-run your Apple watch app.
Run|Options|Application Language
Unfortunately it works only on Xcode 7.2, not on Xcode 7.1. There is no other known possibility.
EDIT
There is a brand new library for language and locale automate testing. It's called AutoMate. The documentation can be found here.
I post my comment for a more readable format.
Hope that can be a "viable" work around
Create the different localization files: English, French, Spanish, Chineseā€¦
localize all elements here
then, open the English files
copy the content of the language you want to test after the present english text (that will supersede it).
To come back to english, delete this added foreign text.
I tested, it works.
I just get an error log, without apparent consequence
Watch Extension[3520:334638] [default] -[SPRemoteInterface _interfaceControllerClientIDForControllerID:]:2140: ComF: clientIdentifier for interfaceControllerID:DC00003 not found
But that is good enough to test localization on simulator.
Removing the extra text clears the error.
I improved this answer.
https://stackoverflow.com/a/54883097/2519218
Change directory to your simulator devices. eg. /Users/$USER_NAME/Library/Developer/CoreSimulator/Devices
Detect your watch simulator. I used ls -trl command after build. eg. 046D5EDA-1808-4BE2-A16E-04DF0324B032
plutil -convert xml1 ./046D5EDA-1808-4BE2-A16E-04DF0324B032/data/Library/Preferences/.GlobalPreferences.plist -o change_global.plist
Edit change_global.plist AppLanguages's section you want to use by vim. I wanted to use ja, so it's like <key>AppleLanguages</key> <array> <string>ja</string> </array>.
Put change_global.plist to ./046D5EDA-1808-4BE2-A16E-04DF0324B032/data/Library/Preferences/.GlobalPreferences.plist. like cp change_global.plist ./046D5EDA-1808-4BE2-A16E-04DF0324B032/data/Library/Preferences/.GlobalPreferences.plist .
Restart simulator.
Unfortunately, it doesn't seem like you can change the language in the watch simulator at this time. On the device, it's located in the iPhone Watch app under General -> Language & Region. However, on the iPhone simulator, there isn't even an option for the General section. This is all that shows up under the Watch app:

How to specify a different bundle display name on iPad (universal app)?

I have tried this in info plist which does not work:
CFBundleDisplayName~ipad = "Full app name"
The iPad still displays only the CFBundleDisplayName which is abbreviated for iPhone.
Is there another approach to get a different bundle display name for iPad in a universal app?
It can be done as stated in the apple document link
In iOS 3.2 and later, apps can designate keys in the Info.plist file as being applicable only to specific types of devices. To create a device-specific key, you combine the key name with some special qualifiers using the following pattern:
key_root-platform~device
In this pattern, the key_root portion represents the original name of the key. The and portions are both optional endings that you can use to apply keys to specific platforms or devices. For the platform key, you can specify a value of iphoneos or macos depending on the platform you are targeting.
I think what you have done is right. Just try to delete the app from the device and build and run again.
As #LebRon suggested I solved it by setting a separate key for iPad and iPhone,
here is a screenshot which solved it for me,
No, there is not a way to do it. In order to understand from a code whether the device is iPhone or iPad, you need runtime. And Bundle Display Name cannot be changed at the runtime.
It was explained here: Dynamically set iOS Bundle Display Name in Xcode 4 on Build

Xcode 5/iOS 7 - localization not working in simulator

I was following one of Ray Wenderlich's tutorials on localization but I can't seem to get it working.
I've set my project up for localization in English and French and I have a locaziable.strings file for each:
The French file has the correct (well as far as Google translate goes) French versions of my string:
I'm setting the strings by calling the correct key from the localizable.strings file:
NSString* strTitle = [NSString stringWithFormat:NSLocalizedString(#"Title", Nil)];
And I have the simulator set to French (BTW: Whenever I do a language change the simulator crashes).
But it is not pulling from the correct localizable.strings file. It's still displaying in English:
Am I doing something wrong?
If you are using xcode 6.1.1 and iOS sdk 8.1,try this workaround.
It seems localization does not work with xCode 6.1 and 8.1 simulator.
Workaround:
Go to "edit schemes" >> "Run" (side bar) >> "Options" tab >> "Application Language"
Select the language you wish to run the app on the simulator.
I got this workaround from Workaround by natanavra
Thanks to him.
However I read on developer forum,that it is working in 6.2 beta version of Xcode. Hope it do.
Maybe you have run the app at some time where the file Localizable.strings already existed but has not been localized yet. If this is the case, this unlocalized file still resides in the resources folder in the application bundle in the simulator (when you build an run a new version of your app in the simulator or in the device, unused files will not be deleted). This can lead to problems.
Try to delete the app completely from the simulator and build an run again.
I have experienced similar issues (IB localization in my case) on device. So general answer would be
Device - Uninstall app and clean project by Shift+CMD+K
Simulator - Go iOS simulator > Reset Content and Settings and clean project by Shift+CMD+K
These problems are really annoying. Along with poor ability to update localized strings is localization one of the biggest drawback of iOS development.
Another problem that could cause localization not work is the encoding of the strings file. Localizable.strings's encoding must be UTF-16. The default encoding of text file in xcode is UTF-8, that cause me spending a whole day to check why the localization not work.
In Xcode 6.0 and later, Localization not work by changing language in Simulator not working.
You have to edit scheme before running your application.
Go to Edit Scheme -> Run -> Options, change language here.
Now, Run Your Application. It will Work.
For more details, check this answer : Changing language on iOS 8.1 simulator does not work
My problem for this was an incorrectly encoded character in the localization file.

Resources