Skip to content

[gen_l10n] Flat inheritance model for subclasses leads to incorrect runtime fallbacks for multi-level locales #187948

Closed

Description

@bkonyi

Description

The gen_l10n tool in Flutter currently generates a flat inheritance model for subclasses (regional and script variants of a language). All subclasses for a given language code extend the base language class directly, rather than forming a hierarchical chain.

This leads to incorrect runtime fallback behavior for multi-level locales (e.g., Language + Script + Region).

Reproduction Steps

Consider the following ARB files in a project:

  1. app_zh.arb (Base Simplified Chinese):
    {
      "@@locale": "zh",
      "dry": "干"
    }
  2. app_zh_Hant.arb (Traditional Chinese):
    {
      "@@locale": "zh_Hant",
      "dry": "乾"
    }
  3. app_zh_Hant_HK.arb (Hong Kong Traditional Chinese - empty, expecting to inherit everything from zh_Hant):
    {
      "@@locale": "zh_Hant_HK"
    }

Expected Behavior:
At runtime, if the app is run in zh_Hant_HK locale, looking up the dry key should return "乾" (inherited from zh_Hant).

Actual Behavior:
The app returns "干" (inherited from zh).

Technical Details

In packages/flutter_tools/lib/src/localizations/gen_l10n.dart, the generator determines the base class for all subclasses using only the languageCode:

final baseClassName = '$className${LocaleInfo.fromString(locale.languageCode).camelCase()}';

Activity

  1. added
    a: internationalizationSupporting other languages or locales. (aka i18n)
    P2Important issues not at the top of the work list
    team-toolOwned by Flutter Tool team
    triaged-toolTriaged by Flutter Tool team
    on Jun 12, 2026
  2. added a commit that references this issue on Aug 19, 2026
    ea647da
  3. github-actions commented on Sep 2, 2026

    @github-actions

    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 -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)team-toolOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions