Repository navigation
Error when generating pt_BR localizations. #138609
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
With new project just add two .arg files:
pt.arb
{
"@@locale": "pt",
"@@last_modified": "2023-11-17T11:23:45+01:00",
"test": "test_PT"
}
pt_BR.arb
{
"@@locale": "pt_BR",
"@@last_modified": "2023-11-17T11:23:45+01:00",
"test": "test_PT_BR"
}
l10n.yam:
arb-dir: lib/l10n
template-arb-file: pt.arb
output-localization-file: app_localizations.dart
When trying to run flutter gen-l10n such error appears:
The locale specified in @@Locale and the arb filename do not match.
Please make sure that they match, since this prevents any confusion
with which locale to use. Otherwise, specify the locale in either the
filename of the @@Locale key only.
Current @@Locale value: pt_BR
Current filename extension: br
Because of that AppLocalizationsPtBr class is not generated.
After small investigation I fount a bug in here: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart
In line: 599
if (parserResult != null && _iso639Languages.contains(parserResult.languageCode)) {
the 'BR' from 'pt_BR' is treated as 'br' - Breton Language Breton
Expected results
I would expect to create class for portuguese brasil language
Actual results
L10nException thrown when generating language class.
Exception: The locale specified in @@locale and the arb filename do not match.
Please make sure that they match, since this prevents any confusion with which locale to use.
Otherwise, specify the locale in either the filename of the @@locale key only.
Current @@locale value: pt_BR
Current filename extension: br
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
% flutter gen-l10n
Because l10n.yaml exists, the options defined there will be used instead.
To use the command line arguments, delete the l10n.yaml file in the Flutter project.
The locale specified in @@Locale and the arb filename do not match.
Please make sure that they match, since this prevents any confusion
with which locale to use. Otherwise, specify the locale in either the
filename of the @@Locale key only.
Current @@Locale value: pt_br
Current filename extension: br
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.1, on macOS 14.1.1 23B81 darwin-arm64, locale en-PL)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] Connected device (2 available)
[✓] Network resources
• No issues found!
Activity
danagbemava-nc commentedon Nov 17, 2023
Reproducible using the code snippets and steps outlined above.
flutter doctor -v
ikso95 commentedon Apr 25, 2024
@danagbemava-nc Any updated on that bug?
neoacevedo commentedon Apr 29, 2024
It happens too with the es variant 419:
But I changed the @@Locale value to es_419 and the filename too and nothing changes.
martinsbrn commentedon Dec 30, 2024
Same situation using the documentation: https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization
if the pt_BR arb file has the @@Locale attribute = pt_BR we got the following message when generating files: "The locale specified in @@Locale and the arb filename do not match (Current @@Locale value: pt_BR - Current filename extension: br)"
l10n.yaml used:
Generated app_localization.dart:
Fix error when generating pt_BR localizations
Fix error when generating pt_BR localizations
Fix error when generating pt_BR localizations (#175832)
Fix error when generating pt_BR localizations (flutter#175832)
Fix error when generating pt_BR localizations (flutter#175832)
github-actions commentedon Dec 11, 2025
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.