iOS localizable.strings stops working after first run - ios

I'm facing this weird problem (both on simulator and device):
My app is localized in many languages, if I build and run the app on the device (as well as on the sim), and the app was not installed, everything seems fine, but than, if I build and run again without removing the app, or if I close and reopen the app manually, the it gets localized in italia as if there is no localizable.strings file and the only language is italian (I'm italian, but both my mac and my Device are in english).
Here's a flow:
1) The device is in Italian -> I build and run the app -> it is localized in italian as it should be.
2) I close the app -> switch the language of my iPhone to english -> reopen the app -> the app is still in italian.
3) I delete the app (with language set to english) -> I build and run the app -> the app is in english as it should be.
4) I close and reopen the app (or build and run again) -> the app switches back to italian even if the device language is in english.
than there's no way to get to english again unless I delete and rebuild the app, and it just works for the first time.
Any idea on this strange behaviour? I'm looking around but find no hint to solve this problem.

In my tests (which have only been on the simulator), you need to either:
A. Turn on/off the device after changing the language
B. Delete the app and reinstall after changing the language
In order to see the language change take effect. I would try turning the device on/off and changing languages settings and see if the language sticks this time.

There was an error in a framework I was using which was setting programmatically the property AppleLanguages to "it" in the user defaults.

Related

iOS - Device language not recognized for localization

I have an app with multiple embedded packages using their own localization files. The app doesn't seem to be picking the localized strings when I change the device language/region, but if I change the language for the app from iPhone Settings -> App -> Language, the language is recognized properly and the correct strings are shown.
Does anyone know of a fix around this? Or if it's a known iOS issue somehow?

UITest localized application

I have an application in French only.
In the storyboard, I have a mix of specifics and system buttons.
When launched on a french device, all is good, the system buttons have french names.
I added the arguments passed on launch in my unique sheme
-AppleLanguages (French)
-AppleLocale fr_FR
so, when launched on the simulator, I have the same result than on a french device.
But when I want to test with UITests, the system buttons have english name (ie Edit/Done), so my tests with tap on button "Modifier" or "Ok" doesn't work.
Is there a way to force the device language before testing the application, or have I missed something?
I didn't find a good solution for this problem.
But I saw that the setting doesn't change between two launches of the iPhone emulator. So I changed the iPhone language to French, and it will be OK until I change the simulator's model or I localize the application for another language.

Localization not working on device

I localized my app in french, created Localizable.strings with appropriate translations, as well for the storyboard.
When I run the app on the french device, storyboard labels are translated correctly, but not the ones coming from Localizable.strings.
I printed preferredLanguages() and NSLocaleLanguageCode and they are correct on the device ("fr").
If I force the language "fr" with the Edit Scheme, it works, but if I go back to "System Language", it does not work anymore.
Reading other posts, I also cleaned, delete app from device, reset content and settings on the simulator, relaunch Xcode, ...
I can't see why the app does not use the language defined on the device for the Localizable.Strings !
Thanks for your help...

How to change iOS simulator language to swedish

I want to change my ios simulator language to swedish, but i can't find this in settings. What can i do now to get swedish language.
It is also possible to set the language and the region via the scheme settings as seen here:
If you are trying to test an application's localisations then there are easier ways than by changing the language on the device.
You can run the apps with a flag to indicate the country:
i.e for Swedish you can use the flag -AppleLanguages (sv)
Of course, on the simulator or the device, you can't run an app with a flag normally, except for when you are building and running it through Xcode, where you can set the launch arguments for each scheme.
I wrote about this in greater detail, with screenshots, and an example project: https://abizern.org/2012/03/18/simple-localisation-testing.html
This works for the simulator and the device, and you don't have to change any of the device settings.
Choose Svenska. You can select the language through the settings just like you would on a real device. Languages are displayed in the target language, not the current language, as displayed in your screenshot.
Tap the row you want, then tap done (click in the case of the simulator). On device, make sure you can navigate back.
For XCode 12
To do this, tap on the active scheme (the name of your app at the left of the active simulator) and then:
Edit Scheme
Run
Options
App Language

Running on iPhone OS 4.0, my app no longer loads localized resource

I have an app for OS 3.0. It is localized for Chinese (in addition to the base support of English).
It works perfectly on all devices with OS 3.0, 3.1.x, even on iPad with 3.2. That is, when I select Chinese in system settings, the app will show resources using Chinese. Localization works in app itself, the settings bundle, and the app name in home screen. (And of course, if system is set to English, my app will show English resources)
However, when running it on 3GS + OS4.0, it always shows English resource no matter what language I choose in system settings. The app itself always shows English, settings bundle is in English, and app name in Home screen shows the English version too.
I tried many things such as restart the device, reinstall the app, add CFBundleLocalizations in info.plist, etc. No help.
What have I done wrong that might cause the localization to fail on OS4.0 (although still works on 3.x)?
Here's my localization folder structure, which I believe is very normal:
+---en.lproj
| InfoPlist.strings
| Localizable.strings
|
\---zh.lproj
InfoPlist.strings
Localizable.strings
Thanks in advance for any suggestions.

Resources