flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.92k stars 27.16k forks source link

[a11y]: `ExpansionTile` state (collapsed and expanded) is always read in English despite changing device language. #154343

Closed leccio closed 1 week ago

leccio commented 2 weeks ago

Steps to reproduce

  1. add an ExpansionTile widget inside the application
  2. use a language other than English

Expected results

The screen reader should read "... expand for more details" in the current locale language

Actual results

The screen reader reads the last part of the message "... expand for more details" always in English, regardless of the current locale language.

Code sample

Code sample ```dart const ExpansionTile( title: Text('Testo scritto e letto in italiano'), subtitle: Text('Sottotitolo in italiano'), children: [ ListTile(title: Text('Ciao Mondo!')), ], ), ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

Doctor output ```console [Paste your output here] ```
darshankawar commented 2 weeks ago

@leccio Are you seeing this on web platform ? If so, can you provide flutter doctor -v ? A couple of related issues were fixed earlier this year that you can check and confirm.

https://github.com/flutter/flutter/issues/143852 https://github.com/flutter/flutter/issues/132264

leccio commented 2 weeks ago

@darshankawar no I am on mobile, both ios and android, the screen reader reads everything with the correct language except for the ExpansionTile widget which for some reason is reads the state always in English. Below the flutter doctor -v

`[✓] Flutter (Channel stable, 3.22.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-IT)
    • Flutter version 3.22.3 on channel stable at /Users/cdottor001/fvm/versions/3.22.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (6 weeks ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/cdottor001/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/cdottor001/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 128.0.6613.86
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!`
darshankawar commented 2 weeks ago

Thanks for the update. I verified this on iOS by changing device language to Spanish for example, and then tapping on ExpansionTile reads most of the text in Spanish, but the state of the Tile is read in English, for example:

Collapsed, double tap to expand. Whereas, it should read the entire text in Spanish. Same goes for the expanded state.

I also checked using SwitchListTile, with which the activate and deactivate states are properly read in Spanish.

runnable code ``` import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: const ExpansionTile( title: Text('Testo scritto e letto in italiano'), subtitle: Text('Sottotitolo in italiano'), children: [ ListTile(title: Text('Ciao Mondo!')), ], ), ), ), ); } } ```
Stable : 3.24.1
Master:  3.25.0-1.0.pre.169
chunhtai commented 1 week ago

You need to add locales to the app inorder to get the translation

e.g.

MaterialApp(
  title: 'Localizations Sample App',
  localizationsDelegates: [ // Need to add these
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
  supportedLocales: [
    Locale('en'), // English
    Locale('es'), // Spanish
  ],
  home: MyHomePage(),
);
leccio commented 1 week ago

@chunhtai it worked, thanks!