Skip to content

[gen_l10n] untranslated-messages-file lists keys that are intentionally inherited from base locale (e.g. en -> en_US) #176020

Description

@radomir9720

Use case

When using Flutter's gen_l10n with a base locale (for example en) and a region-specific locale (for example en_US), the generated Dart classes correctly inherit missing keys from the base locale. However, untranslated-messages-file still lists keys that are absent from the region-specific ARB but present in the base ARB. Those keys are intentionally inherited and not missing translations, so they should not appear in untranslated-messages-file (or there should be a config option to exclude them).

Projects commonly keep region-specific ARB files minimal: they include only keys that need to be overridden for that region; everything else should be inherited from the base locale. Treating inherited keys as "untranslated" produces false positives in untranslated-messages-file, cluttering review workflows and causing unnecessary attention to keys that are intentionally absent.

Reproduction

  1. Files:

app_en.arb

{
  "@@locale": "en",
  "hello": "Hello",
  "greet": "Greetings"
}

app_en_US.arb

{
  "@@locale": "en_US",
  "greet": "Howdy"
}

l10n.yaml

arb-dir: lib/l10n
template-arb-file: app_en.arb
output-class: AppLocalizations
untranslated-messages-file: untranslated_messages.txt
  1. Run flutter gen-l10n (or the regular build that triggers gen_l10n).
  2. Observed result:
  • Generated Dart code: en_US locale correctly inherits "hello" from the base en locale.
  • untranslated_messages.txt contains the key hello (because it is absent in app_en_US.arb), which suggests it's "untranslated"

Proposal

Two reasonable approaches:

  1. Default behavior change: When building untranslated-messages-file, consider inherited keys as translated for the child locale — exclude keys that exist in an ancestor (base) locale.

  2. Opt-in configuration: Add a new l10n setting, for example

exclude-inherited-keys-from-untranslated: true
# or
untranslated-messages-filter: exclude-inherited

When set, gen_l10n would not list keys in untranslated-messages-file that are present in a parent/base ARB file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions