Skip to content

[material_ui, cupertino_ui] Localizations#12119

Open
justinmc wants to merge 322 commits into
flutter:mainfrom
justinmc:flutter_localizations
Open

[material_ui, cupertino_ui] Localizations#12119
justinmc wants to merge 322 commits into
flutter:mainfrom
justinmc:flutter_localizations

Conversation

@justinmc

@justinmc justinmc commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

This PR attempts to solve the flutter_localizations problem for material_ui and cupertino_ui. The crux of the problem is that apps that import flutter_localizations were getting a version of GlobalMaterialLocalizations that uses flutter/flutter's MaterialLocalizations instead of the one in material_ui (and the same thing for Cupertino). This PR moves these classes into material_ui and cupertino_ui, while keeping other localization code inside flutter_localizations.

How this PR was created

Similar to #11888, this PR copies history from flutter/flutter. All commits are preserved as-is, plus one final commit from me that is a squash of all of my work on this PR. This PR should be landed as a merge without squash.

git filter-repo --path-glob "packages/flutter_localizations/lib/src/l10n/cupertino_*.arb" --path packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart --path packages/flutter_localizations/lib/src/cupertino_localizations.dart --path packages/flutter_localizations/test/cupertino/ --path-glob "packages/flutter_localizations/lib/src/l10n/material_*.arb" --path packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart --path packages/flutter_localizations/lib/src/material_localizations.dart --path packages/flutter_localizations/test/material --path packages/flutter_localizations/test/test_utils.dart --path dev/tools/localization/gen_cupertino_localizations.dart --path dev/tools/localization/gen_material_localizations.dart --path dev/tools/localization/language_subtag_registry.dart --path dev/tools/localization/localizations_utils.dart --path dev/tools/localization/localizations_validator.dart --path dev/tools/localization/bin/encode_kn_arb_files.dart --path dev/tools/localization/bin/gen_localizations.dart --path dev/tools/localization/bin/gen_missing_localizations.dart
cd ../packages
git remote add source-origin ../flutter
git fetch source-origin
git merge source-origin/master --allow-unrelated-histories

Before

As described in flutter/flutter#188757, a typical localized app like the following would encounter runtime type errors:

import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:material_ui/material_ui.dart';

After

import 'package:flutter_localizations/flutter_localizations.dart'
    show GlobalWidgetsLocalizations;
import 'package:material_ui/material_ui.dart';

Open Questions

  • I put the l10n folder in side of <material_ui or cupertino_ui>/lib/l10n because that's what the docs said. Should it be in src/?
    • Yes, I've moved it to src/.
  • I put the generation scripts inside of packages/material_ui/tools/l10n. Is there a better spot? Is it ok that cupertino_ui has to use a script inside of material_ui? The reason why I didn't split the scripts in two is that there would be large amounts of code duplication.

TODOs

  • Update l10n README files.
  • Squash all of my own commits.

Resources

Fixes flutter/flutter#188757

Hans Muller and others added 30 commits February 13, 2019 08:35
…nd generate one for cupertino english and french (#29824)
…orted languages (#31644)" (#32470)

This reverts commit 5c3c680.
Corects a bnuch of typeos throuhgout teh Fluter codebsae.

Made use of the `misspell` tool:
https://github.com/client9/misspell
justinmc added 9 commits July 7, 2026 11:45
Moved into cupertino_ui similar to how it was done in material_ui. Both
are now usable.
These were copied from the l10 folder of flutter_localizations and then
modified.
In the previous iteration of this PR, this was done just by copying the
code without history. I anticipate conflicts because of this when I
cherry pick those commits.
@justinmc justinmc force-pushed the flutter_localizations branch from 794b415 to c16ca7b Compare July 7, 2026 18:50
@github-actions github-actions Bot removed the CICD Run CI/CD label Jul 7, 2026
@justinmc justinmc added the CICD Run CI/CD label Jul 7, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Jul 7, 2026
@justinmc justinmc added the CICD Run CI/CD label Jul 7, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Jul 8, 2026
@justinmc justinmc added the CICD Run CI/CD label Jul 8, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Jul 8, 2026
@justinmc justinmc added the CICD Run CI/CD label Jul 8, 2026
@justinmc

justinmc commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

I'm opening this PR to review with two caveats:

  1. If reviewers are on board, I will squash all of my commits into one before merging, keeping all commits from flutter/flutteras-is.
  2. I am still struggling with two test failures that strangely don't reproduce locally:
01:25 +3072 ~6: /b/s/w/ir/x/w/packages/packages/material_ui/test/l10n/date_time_test.dart: ar is initialized correctly when DateFormat is used
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: '٨:٣٠ م'
  Actual: '8:30 م'
   Which: is different.
          Expected: ٨:٣٠ م
            Actual: 8:30 م
                    ^
           Differ at offset 0
01:28 +3198 ~6 -1: /b/s/w/ir/x/w/packages/packages/material_ui/test/l10n/date_picker_test.dart: CalendarDatePicker shows dates for ar_AR
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: exactly one matching candidate
  Actual: _TextWidgetFinder:<Found 0 widgets with text "سبتمبر ٢٠١٧": []>
   Which: means none were found but one was expected

@justinmc justinmc marked this pull request as ready for review July 8, 2026 21:42
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@justinmc justinmc Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@stuartmorgan-g this and related scripts in this directory generate localization files for both material_ui and cupertino_ui. I avoided putting them in the root /scripts directory of this repo because I didn't want to pollute that with something that's specific to only 2 packages. What do you think is the better place for these scripts?

CC @QuncCccccc

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.

If we want the script in material_ui, I think we might want it to be in material_ui/tool/ instead of material_ui/script/. See here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD p: cupertino_ui p: material_ui triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[decoupling] Using flutter_localizations with material_ui/cupertino_ui