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
- 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
- Run flutter
gen-l10n (or the regular build that triggers gen_l10n).
- 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:
-
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.
-
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.
Use case
When using Flutter's
gen_l10nwith a base locale (for exampleen) and a region-specific locale (for exampleen_US), the generated Dart classes correctly inherit missing keys from the base locale. However,untranslated-messages-filestill 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 inuntranslated-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
app_en.arb{ "@@locale": "en", "hello": "Hello", "greet": "Greetings" }app_en_US.arb{ "@@locale": "en_US", "greet": "Howdy" }l10n.yamlgen-l10n(or the regular build that triggersgen_l10n).en_USlocale correctly inherits"hello"from the baseenlocale.untranslated_messages.txtcontains the keyhello(because it is absent inapp_en_US.arb), which suggests it's "untranslated"Proposal
Two reasonable approaches:
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.Opt-in configuration: Add a new
l10nsetting, for exampleWhen set,
gen_l10nwould not list keys inuntranslated-messages-filethat are present in a parent/base ARB file.