Skip to content

[gen_l10n] Preserve script locale inheritance for regional subclasses - #190956

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
Boulea7:fix-gen-l10n-locale-hierarchy-187948
Aug 19, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
Boulea7:fix-gen-l10n-locale-hierarchy-187948

Conversation

@Boulea7

@Boulea7 Boulea7 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a locale contains language, script, and country subtags, generate its localization subclass from the matching script-only locale when that locale exists. If it does not exist, retain the existing language-level fallback.

The generated script class keeps its public zero-argument constructor and adds a private forwarding constructor for regional subclasses so the full locale name is preserved. Untranslated-message reporting now follows the same inheritance chain.

Fixes #187948.

Tests

  • dart test test/general.shard/generate_localizations_test.dart --name 'uses a script locale as the parent for a regional locale|selects parent locales for script and country combinations'
  • dart test test/general.shard/generate_localizations_test.dart test/general.shard/build_system/targets/localizations_test.dart test/commands.shard/hermetic/generate_localizations_test.dart
  • dart test test/integration.shard/gen_l10n_test.dart --concurrency=1
  • dart analyze --fatal-infos lib/src/localizations/gen_l10n.dart test/general.shard/generate_localizations_test.dart
  • flutter analyze lib/src/localizations/gen_l10n.dart test/general.shard/generate_localizations_test.dart
  • dart format --output=none --set-exit-if-changed lib/src/localizations/gen_l10n.dart test/general.shard/generate_localizations_test.dart

AI assistance disclosure

Codex assisted with implementation, tests, and verification.

Pre-launch Checklist

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 11, 2026
@Boulea7
Boulea7 marked this pull request as ready for review August 12, 2026 19:40

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the localization generator in gen_l10n.dart to correctly resolve parent locales for script and country combinations, ensuring that regional subclasses inherit from their script-specific parent locales rather than defaulting directly to the base language locale. It also updates the unimplemented message detection to check the entire inheritance chain and introduces a private _withLocale constructor to preserve public constructors. Corresponding unit tests have been added to verify these inheritance hierarchies. There are no review comments, so I have no feedback to provide.

@bkonyi bkonyi added the CICD Run CI/CD label Aug 18, 2026
@bkonyi
bkonyi requested review from bkonyi and chingjun August 18, 2026 15:23

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We just need one more review before this can land.

Change-Id: I2479a0159543569cfd2943a076f1c1156b840d76
@chingjun
chingjun force-pushed the fix-gen-l10n-locale-hierarchy-187948 branch from 90fdddf to 6086634 Compare August 18, 2026 19:22
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 18, 2026
@chingjun chingjun added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Aug 18, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 18, 2026
Merged via the queue into flutter:master with commit ea647da Aug 19, 2026
29 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2026
@bkonyi bkonyi added the cp: stable cherry pick this pull request to stable release candidate branch label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: stable cherry pick this pull request to stable release candidate branch tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants