flutter / flutter/flutter

Platform.localname returns "de_DE" instead of "de_CH" for Swiss German under Windows (iOS and MacOS work correctly)

Open
#143,373 4 comments 5 reactions 0 assignees View on GitHub
a: internationalization engine found in release: 3.16 found in release: 3.20 has reproducible steps P2 platform-windows team-windows triaged-windows
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

1. Set regional settings to "Swiss German" under Windows 11 (see screenshot)
2. Create a new flutter project
3. call print(Platform.localeName);

Dart itself is probably correct. Flutter supposedly has a seaparate implementation for the locale, which has this issue. See comment: https://github.com/dart-lang/sdk/issues/54904

### Expected results

Platform.localname and findSystemLocale() should return the correct value "de_CH" for Swiss German under Windows

### Actual results

Today Platform.localname returns the wrong code "de_DE" instead of "de_CH" for Swiss German under Windows. The effect is that the wrong currency "EUR" instead of "CHF" is used under Windows.
On macOS and iOS, however, the code is returned correctly!

### Code sample

Code sample

```dart
import 'dart:io';

void main() {
// returns "de_DE" instead of "de_CH"
print(Platform.localeName);
}
```

### Screenshots or Video

Regional settings with "Swiss German" under Windows 11:

![image](https://github.com/flutter/flutter/assets/97222956/60615c82-5040-41a2-a38e-acbc1e13877a)

### Logs

Logs

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

### Flutter Doctor output

Doctor output

```console
flutter doctor -v
[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.22621.3007], locale de-CH)
• Flutter version 3.16.9 on channel stable at C:\develop\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 41456452f2 (3 weeks ago), 2024-01-25 10:06:23 -0800
• Engine revision f40e976bed
• Dart version 3.2.6
• DevTools version 2.28.5

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\st-ro\AppData\Local\Android\sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.5)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.8.34511.84
• Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.1)
• Android Studio at C:\Program Files\Android\Android Studio
• 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.7+0-b2043.56-10550314)

[√] VS Code (version 1.86.0)
• VS Code at C:\Users\st-ro\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.50.0

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.3007]
• Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.161
• Edge (web) • edge • web-javascript • Microsoft Edge 121.0.2277.112

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

• No issues found!

```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Windows 11 case with dart:io's Platform.localeName and findSystemLocale(), then compare Flutter's separate locale implementation with the linked Dart SDK issue. Done means both APIs return de_CH for Swiss German on Windows, matching the existing behavior on macOS and iOS.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
localization, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.