Repository: flutter
Issue: [Proposal] Add support for ARB files with 3-letter language codes
Labels: c: new feature,tool,a: internationalization,c: proposal,P3,team-tool,triaged-tool

`gen-l10n` does not accept `.arb` files with 3-letter (alpha3-b and alpha3-t) language codes.

In [ubuntu-desktop-installer](https://github.com/canonical/ubuntu-desktop-installer), we would like to include languages such as "ast" and "szl". For reference, here's the full list of languages supported by the previous generation Ubiquity installer: https://git.launchpad.net/ubiquity/tree/d-i/source/localechooser/languagelist.

In https://github.com/flutter/flutter/pull/60185, a check was added that [`.arb` language codes must be on the list of ISO 639-1 alpha2 language codes](https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart#L460). Since then, the list was already hand-edited to include a couple of ISO 639-2 alpha3-b codes (fil=filipino, gsw=swiss german) which happen to be used by the Flutter gallery: flutter/flutter#60632. However, there are plenty of other languages on the alpha3-b and alpha3-t code lists that don't have an alpha2 code (see at the bottom).

## Steps to Reproduce

1) Clone [gen_l10n_example](https://github.com/flutter/website/tree/main/examples/internationalization/gen_l10n_example)
2) Create `lib/l10n/ast_ES.arb` (e.g. copy one of the existing ARB files to `app_ast_ES.arb`)
3) Run `flutter gen-l10n`:
  ```
  Multiple arb files with the same 'es' locale detected. 
  Ensure that there is exactly one arb file for each locale.
  ```
4) Try being more explicit and add `"@@locale": "ast_ES"` to `ast_ES.arb`:
  ```
  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: ast_ES
  Current filename extension: es
  ```

<details>
<summary>Code sample</summary>

gen_l10n_example/lib/l10n/app_ast_ES.arb:
```json
{
    "@@locale": "ast_ES",
    "helloWorld": "¡Hola Mundo!"
}
```
</details>

<details>
  <summary>Logs</summary>

Without `@@locale`:
```bash
$ cat lib/l10n/app_ast_ES.arb 
{
    "helloWorld": "¡Hola Mundo!"
}

$ 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.


Multiple arb files with the same 'es' locale detected. 
Ensure that there is exactly one arb file for each locale.
```

With `"@@locale": "ast_ES"`:
```bash
$ cat lib/l10n/app_ast_ES.arb 
{
    "@@locale": "ast_ES",
    "helloWorld": "¡Hola Mundo!"
}

$ 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: ast_ES
Current filename extension: es
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

The issue is reproducible with both the stable and the master channel.

```
$ flutter doctor -v
[✓] Flutter (Channel stable, 2.5.3, on Ubuntu 21.10 5.13.0-20-generic, locale en_US.UTF-8)
    • Flutter version 2.5.3 at /home/jpnurmi/.fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (2 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/jpnurmi/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_SDK_ROOT = /home/jpnurmi/Android/Sdk
    • Java binary at: /home/jpnurmi/Android/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 13.0.0-2
    • cmake version 3.18.4
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2020.3)
    • Android Studio at /home/jpnurmi/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 11.0.10+0-b96-7249189)

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension version 3.27.0

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Ubuntu 21.10 5.13.0-20-generic

• No issues found!
```

```
$ flutter doctor -v
[✓] Flutter (Channel master, 2.6.0-12.0.pre.535, on Ubuntu 21.10 5.13.0-20-generic, locale en_US.UTF-8)
    • Flutter version 2.6.0-12.0.pre.535 at /home/jpnurmi/Flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 04156b6636 (2 days ago), 2021-10-29 18:29:31 -0700
    • Engine revision 3a0a63c2d2
    • Dart version 2.15.0 (build 2.15.0-262.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/jpnurmi/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_SDK_ROOT = /home/jpnurmi/Android/Sdk
    • Java binary at: /home/jpnurmi/Android/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 13.0.0-2
    • cmake version 3.18.4
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2020.3)
    • Android Studio at /home/jpnurmi/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 11.0.10+0-b96-7249189)

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension version 3.27.0

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Ubuntu 21.10 5.13.0-20-generic

• No issues found!
```

</details>

For a full list of language codes, see ["language-codes-full"](https://datahub.io/core/language-codes#resource-language-codes-full) at datahub.io, where [Flutter's alpha2 code list](https://github.com/flutter/flutter/blob/04156b66364b6be646432cc77487c108fc19f378/packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart#L581) was originally taken from.

![image](https://user-images.githubusercontent.com/140617/139651163-81718dac-f59d-41a6-9149-e7f8425d4a8a.png)