这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@chunhtai
Copy link
Contributor

toward #98948

This sets the ground work for framework and web

still need to implement:

  1. Android and iOS support
  2. set application locale.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-web Web applications specifically labels Jun 25, 2025
@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label Jun 26, 2025
Comment on lines +5108 to +5112
if (localeForChildren != configProvider.effective.locale) {
configProvider.updateConfig((SemanticsConfiguration config) {
config.locale = localeForChildren;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment here explaining why we are not always setting the locale?

I presume this is done to avoid excessive adding of lang attribute as described here:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is to update the locale only if it is different.

As for this diagram, I am starting to think whether just set lang for every div will be easier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I misunderstood this code.

Look at my other comment for a potentially easy way to achieve this on web.

/// {@macro flutter.widgets.ProxyWidget.child}
final Widget? child;

/// Whether this is the main localizations with for that represent the app's
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Whether this is the main localizations with for that represent the app's
/// Whether this is the main localizations widget that represent the app's

// If this is not application level, we need to explicit mark the
// semantics subtree with the locale.
localeForSubtree: widget.isApplicationLevel ? null : widget.locale,
container: !widget.isApplicationLevel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make it always a container?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason this has to be a container if we set localeForSubtree is to prevent it merge up that end up including sibling renderobject to be under it.

for isApplicationLevel is true, it doesn't set localeForSubtree so no need to force it to container. I will have a follow up pr that adds a dart:ui API to set the application locale directly if isApplicationLevel is set to true

@github-actions github-actions bot added f: scrolling Viewports, list views, slivers, etc. platform-windows Building on or for Windows specifically a: desktop Running on desktop labels Jun 26, 2025
Comment on lines 821 to 831
void _updateLocale() {
final String locale = semanticsObject.locale?.toString() ?? '';
if (locale.isEmpty) {
removeAttribute('lang');
return;
}
setAttribute('lang', locale);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do something like this to avoid setting the lang attribute everywhere:

Suggested change
void _updateLocale() {
final String locale = semanticsObject.locale?.toString() ?? '';
if (locale.isEmpty) {
removeAttribute('lang');
return;
}
setAttribute('lang', locale);
}
void _updateLocale() {
final String locale = semanticsObject.locale?.toString() ?? '';
final isSameAsParent = semanticsObject.locale == semanticsObject.parent?.locale;
if (locale.isEmpty || isSameAsParent) {
removeAttribute('lang');
return;
}
setAttribute('lang', locale);
}

Comment on lines +5108 to +5112
if (localeForChildren != configProvider.effective.locale) {
configProvider.updateConfig((SemanticsConfiguration config) {
config.locale = localeForChildren;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I misunderstood this code.

Look at my other comment for a potentially easy way to achieve this on web.

@chunhtai chunhtai requested a review from a team as a code owner June 27, 2025 17:02
@github-actions github-actions bot added platform-ios iOS applications specifically team-ios Owned by iOS platform team labels Jun 27, 2025
@github-actions github-actions bot removed platform-ios iOS applications specifically team-ios Owned by iOS platform team labels Jun 27, 2025
@chunhtai chunhtai requested a review from hannah-hyj June 30, 2025 18:45
Copy link
Member

@hannah-hyj hannah-hyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 30, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 30, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Jun 30, 2025

autosubmit label was removed for flutter/flutter/171196, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@chunhtai
Copy link
Contributor Author

chunhtai commented Jul 2, 2025

migrating internal code cl/778235479

Nothing functionally wrong, but internal code relies on implicit merging of semantics tree. Since this pr adds a container to the localization widget, it messes with the implicit merging of customer's app.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 7, 2025
@hannah-hyj hannah-hyj mentioned this pull request Jul 8, 2025
9 tasks
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

toward flutter#98948

This sets the ground work for framework and web

still need to implement:
1. Android and iOS support
2. set application locale.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: desktop Running on desktop a: tests "flutter test", flutter_test, or one of our tests engine flutter/engine related. See also e: labels. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-web Web applications specifically platform-windows Building on or for Windows specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants