Repository: flutter
Issue: Error when generating pt_BR localizations.
Labels: tool,a: internationalization,has reproducible steps,P2,team-tool,triaged-tool,found in release: 3.16,found in release: 3.17

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### 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](https://en.wikipedia.org/wiki/Breton_language) 



### 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

<details><summary>Code sample</summary>

```dart
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.
    );
  }
}

```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details><summary>Logs</summary>

 % 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

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
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!

```

</details>