Skip to content

Multiple problems with VoiceOver on iOS not using the correct locale. #99018

@Leffe108

Description

@Leffe108

Voice Over usage hints

When VoiceOver is active you tap once on buttons etc. to select them and then double-tap to activate them. If you feel lost, engage Siri and say "VoiceOver" and you can tap the switch and then double tap to disable. In my experience saying "VoiceOver" to bring up that setting works regardless of the activated system language.

If your device does not have a home button, to swipe from bottom while VocieOver is activated you have to long press at the bottom of your screen until you hear a sound, then swipe up until it gives a second sound, then release your finger.

Steps to Reproduce

  1. flutter create bug_locale
  2. replace lib/main.dart with code sample
  3. Build in Xcode and run on an physical device. Continue to next step when the app has started on your device.
  4. Go to iOS home screen => settings => language and change language to Italian. (or any other language that is not en-US, en-UK or Danish)
  5. Use Siri and say "Voice Over". It will surface the setting to enable VoiceOver. Tap to enable it.
  6. Use app switcher to go to bug_locale.
  7. Swipe down with two fingers. This is the command to VoiceOver to read the contents of the screen.

Expected results:
I expect that the screen reader is using the corresponding voice for the different texts. See the list below of expected voices of each text:

  • "Hello World" - UK English voice
  • UK Text (no override)" - UK English voice
  • "UK Text (using override)" - UK English voice
  • "American text" - US English voice
  • "Dansk text" - Danish voice
  • "Localizations.override på dansk." - Danish voice

Actual results:

  • Wrong: "Hello World" is spoken with Italian voice
  • Wrong: "UK Text (no override)" is spoken with Italian voice
  • Correct: "UK Text (using override)" is spoken with UK English voice
  • Correct: "American text" is spoken with US English voice
  • Correct: "Dansk text" is spoken with Danish voice
  • Wrong: "Localizations.override på dansk." is spoken with Italian voice.

Turn on audio:

flutter.ios.mp4

Problems:

  1. The locale set in MaterialApp is not communicated to VoiceOver. So any text that doesn't have an explicit override uses system voice (Italian in the reproduction case).
  2. Localizations.override to set the locale of a sub tree does not affect VoiceOver.

Related issues

References

Code sample - lib/main.dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      supportedLocales: const [
        Locale('en', 'UK'),
      ],
      locale: const Locale('en', 'UK'),
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Hello World!'), // should be voiced with UK Engilsh voice (app default)
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('Regular text without locale override. Should use UK voice.'), // should be vocied with UK English vocie (app default)
            Container(height: 20.0),
            const Text.rich(
              TextSpan(children: [
                TextSpan(text: 'UK text (no override). '), // should be vocied with UK English vocie (app default)
                TextSpan(text: 'UK text (using override). ', locale: Locale('en', 'UK')), // should be voiced with UK English vocie
                TextSpan(text: 'American text. ', locale: Locale('en', 'US')), // should be voiced with US English voice
                TextSpan(text: 'Dansk text. ', locale: Locale('da', 'DK')), // should be voiced with Danish vocie
              ]),
            ),
            Container(height: 20.0),
            Localizations.override(context: context,
              locale: const Locale('da', 'DK'),
              child: const Text('Localizations.override på dansk.'), // should be voiced with Danish voice
            ),
          ],
        ),
      ),
    );
  }
}
Logs

Unfortunately I don't have flutter doctor -v as I lend a mac to build this and do not have access to the mac right now. But it was stable channel obtained via git ca 18:00 UTC 2022-02-23. Thus it should be 2.10.2.

I acknowledge that problem point 1 and 2 ideally maybe should have had separate issues. However I only have sparse access to a mac and it takes some time to reproduce this so I combined them in the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: internationalizationSupporting other languages or locales. (aka i18n)found in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions