Skip to content

Set locale of subtree #98835

@Leffe108

Description

@Leffe108

Use case

There are situations when app UI is in one language and it will show content of a different language. In HTML it is possible to markup this content of a foreign language with the lang attribute so that assistive technology like VoiceOver can use the right voice engine for that content.

Single word from other language

I have an app where the UI is in Swedish:

      supportedLocales: [
        const Locale('sv', 'SE'), // Swedish
      ],

But the name of the app contains the English word "Quiz". However VoiceOver struggle to read it out correctly when it uses the Swedish voice engine (it is almost silent gibberish). So I want to provide metadata that this text is in English.

Here is a audio recording on how bad it sounds when Swedish voice is used to read out "quiz" from my Flutter app:

flutter.mp4

In HTML I can do this:

<html lang="sv-SE"><body>
<p>Välkommen till TSP <span lang="en-UK">Quiz</span></p>
</body></html>

demo

multi-locale-html.mp4

Note: Turn on sound on the video. Audio description: It says "Välkommen till TSP" with Swedish voice. Then switches to UK voice and says "Quiz".

Content reader app

Another use case could be a content reader app like a news feed app. It could consume news items from different sources of more than one language. The app UI would remain in one language while user uses the app. But the article content would be great if it can be marked up as the correct locale so VocieOver is able to pick a suitable voice engine for the content to read up.

Proposal

  • A new widget that takes a locale and a child which sets the locale of the subtree.
  • Some widgets like Semantics, Text or TextSpan could as shortcuts have a locale property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions