Showing posts with label bilingual. Show all posts
Showing posts with label bilingual. Show all posts

Wednesday, February 6, 2019

How hard can it be to configure an iOS app to make sure that VoiceOver switches to the app's language? (Answer: really, really hard)

In a previous post, I described how to configure the iOS screen reader VoiceOver to handle multiple languages, allowing the user to manually switch to the language of an app.

This is something that screen reader users who are proficient in more that one language almost always need to change manually when they want to use an app that is not localised to the device's system locale.

However, it doesn't seem to be impossible to configure apps to trigger VoiceOver to switch language automatically. When using VoiceOver with Safari, it switches to the language specified in the document.

I decided to investigate what programmers need to do to in order to make the screen reader switch language automatically in an app. In fact, I was on the verge of promising to do so in my previous post about manually changing the language that VoiceOver uses. Luckily I came to my senses and remembered that I should never assume that I can perform a housekeeping task in Xcode, no matter how normal and straightforward I think the task should be. After a lot of experimentation and some helpful suggestions, I have finally found a solution, so here goes.

There is a setting called Localization native development region in Info.plist but the graphical editor has a short list of languages. You can change it to another language if you switch to the source editor, but it does not take effect in the project settings. So after changing Info.plist, you need to edit the project file as well:
  1. Close the project in Xcode and open the file project.pbxproj in an external editor. 
  2. Search the file for properties called developmentRegion and knownRegions. Replace "en" with the actual locale.
The changes will be reflected on the project's info panel. Attempting to achieve the same result from the Xcode graphic editor does not seem to completely get rid of English in the settings above.

Now we've told the app what its locale is, and that it only has one known locale. Or? Frustratingly, though it seems highly plausible that the locale used to display strings in the app correlates with the desired VoiceOver language, it has no effect on what VoiceOver thinks it should do. It doesn't matter what you do with the project localization settings, having a base language or not - I tried.  Short of providing support for the system locale, the correct language does not get picked.

After asking for help on stack overflow I got a tip from the user Mats which led to a solution: setting the accessibilityLanguage in code in the application. Modify didFinishLaunchingWithOptions with the following addition:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Insert your application's locale
        application.accessibilityLanguage = "sv"
        return true

    }

This finally triggers the screen reader to read the accessible elements in the app in the selected language.

Note that anybody who has written an accessible application should set the accessibilityLanguage, whether the app is localised or not, as you could have users who whose device's system locale is one that you do not support. For localised applications, you will need to detect which locale was used and match the accessibilityLanguage to that one.


Tuesday, February 5, 2019

Configuring the iOS screen reader VoiceOver to work with more than one language

A quick tip for users who need for the iOS screenreader VoiceOver to work with more than one language.

By default when you turn on VoiceOver, the screenreader language is the same as the device's default language. But what if you have apps in another language, or want to visit websites in another language?

You can switch language on the go by navigating to the VoiceOver Speech settings, that is, open General, Accessibility, VoiceOver, Speech. At the end of this view, there is a section called ROTOR LANGUAGES. You can additional languages as needed.

Switch language on the fly by opening the rotor, turning until you hear the languages setting and flicking up and down to find the desired language (more information on using the rotor in Apple's guide to the VoiceOver rotor).

It is reasonably common for web sites to identify the language of the content, and where this has been done, and it seems that the VoiceOver/Safari combo automatically picks the right language if it has been configured, i.e. there is no need to actively change the language in the rotor.

For apps the situation is different. I have as yet not been able to figure out what would trigger an automatic language change in a native iOS app (whereas VoiceOver does switch language in apps that rely on displaying web content if that has language markup).  Specifying the base language for the app, and ensuring that the locale configuration does not contain any leftover language files does not seem to be sufficient. I'll add an update if I find a solution.

Update: the solution is posted in How hard can it be to configure an iOS app to make sure that VoiceOver switches to the app's language? (Answer: really, really hard)

New behaviour of navigation controllers in IOS 13

I resumed working on an app that had been resting for a few weeks (while I had updated to iOS 13) and thought, Whaaat? Navigation controll...