UITest localized application - ios

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.

Related

How can I test app localization?

I am testing that a specific app that is in English also works in Hebrew. In iPad Settings, my region is set to Israel, and I've changed the Language Settings from English to Hebrew. I tried restarting the app and the iPad, but the app text is still in English.
Some of the apps on my iPad have switched to Hebrew, but others are still in English.
What am I doing wrong?
See screenshots.some apps are still in English some apps are still in English
You need to change schema run options as described here
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPInternational/TestingYourInternationalApp/TestingYourInternationalApp.html
You will not need to change device/simulator region or language settings.

iOS App Default Language

I have an app that support both Chinese and English, and when my phone is configured to Chinese or English, things display quite normally, but when my phone is in French(by default the interface would be in English), everything is in English EXCEPT the UIActivityViewController is in Chinese that will pop up once user click a "share" button in my app.
I do not know how to modify this, any helps will be appreciated.
Note: my app uses a Localize-Swift library which allows user to choose a desired language from the settings within the app which means the app language could be different from the system language, if user chooses one from the app then switch to another system lang. Also, English IS set to be the development language in Xcode and Base Localization is NOT used.

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...

iOS localizable.strings stops working after first run

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.

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

Resources