Repository navigation
Multiple problems with VoiceOver on iOS not using the correct locale. #99018
Description
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
flutter create bug_locale- replace lib/main.dart with code sample
- Build in Xcode and run on an physical device. Continue to next step when the app has started on your device.
- 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)
- Use Siri and say "Voice Over". It will surface the setting to enable VoiceOver. Tap to enable it.
- Use app switcher to go to bug_locale.
- 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:
- The locale set in
MaterialAppis not communicated to VoiceOver. So any text that doesn't have an explicit override uses system voice (Italian in the reproduction case). - 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.
Activity
danagbemava-nc commentedon Feb 28, 2022
Reproducible on
stableandmaster.In my testing, the device language was set to French.
code sample
video
RPReplay_Final1645791592.MOV
flutter doctor -v
goderbauer commentedon Mar 2, 2022
/cc @chunhtai
chunhtai commentedon Mar 2, 2022
This is WAI
The MaterialApp.locale is for text localization, such as CupertinoLocalizations and MaterialLocalizations, when you want to display different text based on different locale. It is different from the TextSpan.locale which will override the voiceover locale when it read the text. TextSpan.locale is used when you are sure that text span should be pronounced in a certain language regardless of the voiceover locale user is running on.
Leffe108 commentedon Mar 5, 2022
Thank you for the attention.
I find it a bit confusing that
localeattribute does different things on different widget. Made a proposal on how to document current facilities in the docs.I do think that
MaterialApp.localeand alsoLocalizations.overrideshould be propagated to assistive tech, but I understand that is technically a feature request to be made.github-actions commentedon Mar 19, 2022
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.