Repository navigation
Description
Steps to reproduce
- Run
flutter create --platforms web bugand replacelib/main.dartwith the code sample below. - Run
flutter build web, then serve it withpython3 -m http.server -d build/web. - Open http://localhost:8000 and wait for it to show "Hola", which is inside a
Localizations.overrideforLocale('es', 'US'). - Run this in the DevTools console:
document.documentElement.lang - Click anywhere on the page. "Hola" becomes "Hello", which is outside any override.
- Run the same query again.
Expected results
"en-US" both times. That is the app's own locale, the first of WidgetsApp's default supportedLocales. The Localizations.override docs say it "Overrides the inherited Locale or LocalizationsDelegates for child", and point to WidgetsApp.locale for changing the locale of an entire app.
Actual results
"es-US" both times. A subtree override sets the language of the whole page, and the page keeps it after the override leaves the tree. After the click, the <flutter-view> element matches :lang(es) and not :lang(en), so the browser treats the whole app as Spanish. The same app with _showOverride starting false gives "en-US".
Measured on 3.47.7 stable and on master at 56f0dcb, in release builds, with Playwright's Chromium 156, Firefox 157 and WebKit 27.2 builds. A --wasm build gives the same result in Chromium. Firefox and WebKit did not load the wasm module.
_LocalizationsState.locale's setter calls platformDispatcher.setApplicationLocale for every Localizations, including the one Localizations.override creates, which leaves isApplicationLevel at its default of false. On web, setApplicationLocale passes the locale to every view, and the full-page embedding writes it to <html lang>. Nothing calls it again when the override is disposed, and the app-level Localizations only calls it when its own locale changes.
Calling setApplicationLocale only when widget.isApplicationLevel is true fixes the repro. With that change applied to 3.47.7, it gives "en-US" both times in all three engines, and the app without the override still gives "en-US". The same file already checks isApplicationLevel before setting localeForSubtree.
The call came in #175100, and #177284 made the web engine act on it. No framework test checks what a nested Localizations sends.
Only web was run. From reading the source, Android and iOS receive the override's locale too, since the call is in the framework.
Related: #194688, where the override's own subtree gets lang="es_US".
Code sample
Code sample
import 'package:flutter/widgets.dart';
void main() => runApp(const App());
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
bool _showOverride = true;
@override
Widget build(BuildContext context) {
return WidgetsApp(
color: const Color(0xFF000000),
builder: (context, _) => GestureDetector(
behavior: HitTestBehavior.opaque,
// Tap anywhere to remove the override.
onTap: () => setState(() => _showOverride = false),
child: _showOverride
? Localizations.override(
context: context,
locale: const Locale('es', 'US'),
child: const Text('Hola'),
)
: const Text('Hello'),
),
);
}
}Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Home directory paths, the iPhone's name and device IDs are replaced with <redacted>. The runs used Playwright's browsers, not the Chrome 155 listed here.
Doctor output
[✓] Flutter (Channel stable, 3.47.7, on macOS 26.5.1 25F80 darwin-arm64, locale en-US) [530ms]
• Flutter version 3.47.7 on channel stable at <redacted>/fvm/versions/3.47.7
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision abaf9c5237 (10 days ago), 2026-10-08 09:51:21 -0700
• Engine revision deb287481e
• Dart version 3.13.5
• DevTools version 2.60.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [1,428ms]
• Android SDK at <redacted>/Library/Android/sdk
• Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
• Platform android-36.1, build-tools 36.1.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 25.0.3+-15898627-b508.16)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 26.3) [1,214ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17C529
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [4ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (4 available) [12.0s]
• Pixel 7 Pro (mobile) • <redacted> • android-arm64 • Android 17 (API 37)
• <redacted> (mobile) • <redacted> • ios • iOS 26.7.1 23H30
• macOS (desktop) • macos • darwin-arm64 • macOS 26.5.1 25F80 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 155.0.8059.80
[✓] Network resources [582ms]
• All expected network resources are available.
• No issues found!
Activity
suryaKommana2662 commentedon Oct 20, 2026
@T-Davis Thanks for the report. I was able to reproduce the issue. After clicking to remove the
Localizations.overridesubtree, the text changes fromHolatoHello, butdocument.documentElement.langremainses-USinstead of the expecteden-US.Flutter Doctor Output
7 remaining items
Renzo-Olivares commentedon Oct 20, 2026
from triage: routing to web team for further investigation but feel free to route back to framework if this is not the case.
Only call setApplicationLocale for application-level Localizations (f…
Only call setApplicationLocale for application-level Localizations (f…
Only call setApplicationLocale for application-level Localizations (f…
github-actions commentedon Nov 4, 2026
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.