Skip to content

Only call setApplicationLocale for application-level Localizations - #194892

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
kevmoo:issue-194696
Oct 21, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
kevmoo:issue-194696

Conversation

@kevmoo

@kevmoo kevmoo commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Guard PlatformDispatcher.setApplicationLocale in _LocalizationsState.locale behind widget.isApplicationLevel so subtree Localizations and Localizations.override widgets do not overwrite the application-wide locale (<html lang> on Web and fallback accessibility locales on Android/iOS).

Fixes #194696

Pre-launch Checklist

Guard `PlatformDispatcher.setApplicationLocale` in `_LocalizationsState.locale` behind `widget.isApplicationLevel` so subtree `Localizations` and `Localizations.override` widgets do not overwrite the application-wide locale.

Fixes flutter#194696
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modifies _LocalizationsState in localizations.dart to only update the application locale via WidgetsBinding.instance.platformDispatcher.setApplicationLocale if widget.isApplicationLevel is true. It also adds a corresponding widget test in localizations_test.dart to verify that the locale is not sent to the engine when Localizations is not at the application level. I have no feedback to provide.

@kevmoo
kevmoo requested a review from chunhtai October 20, 2026 21:11
@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Oct 20, 2026

@chunhtai chunhtai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, I probably missed this, thanks for fixing.

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 21, 2026
Merged via the queue into flutter:master with commit 7f075d3 Oct 21, 2026
27 of 28 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2026
@kevmoo
kevmoo deleted the issue-194696 branch October 21, 2026 01:12
LongCatIsLooong pushed a commit to LongCatIsLooong/flutter that referenced this pull request Oct 22, 2026
…lutter#194892)

Guard `PlatformDispatcher.setApplicationLocale` in
[`_LocalizationsState.locale`](https://github.com/flutter/flutter/blob/115a15fbf1fd9c6ae4173fff892fd0075eef069d/packages/flutter/lib/src/widgets/localizations.dart#L641-L648)
behind `widget.isApplicationLevel` so subtree `Localizations` and
`Localizations.override` widgets do not overwrite the application-wide
locale (`<html lang>` on Web and fallback accessibility locales on
Android/iOS).

Fixes flutter#194696

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[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
[flutter/website]: https://github.com/flutter/website
[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
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…lutter#194892)

Guard `PlatformDispatcher.setApplicationLocale` in
[`_LocalizationsState.locale`](https://github.com/flutter/flutter/blob/115a15fbf1fd9c6ae4173fff892fd0075eef069d/packages/flutter/lib/src/widgets/localizations.dart#L641-L648)
behind `widget.isApplicationLevel` so subtree `Localizations` and
`Localizations.override` widgets do not overwrite the application-wide
locale (`<html lang>` on Web and fallback accessibility locales on
Android/iOS).

Fixes flutter#194696

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[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
[flutter/website]: https://github.com/flutter/website
[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] Localizations.override sets <html lang> for the whole page and does not restore it

2 participants