Repository navigation
Conversation
Internationalization page: - Remove the outdated statement that `flutter create` hasn't yet been updated to use `material_ui` by default. - Replace the `as flutter_localizations` prefix import with the `material_ui` import that the unprefixed `GlobalMaterialLocalizations.delegates` code actually relies on, and warn about the `ambiguous_import` conflict. - Clarify delegate choices for `CupertinoApp` and `WidgetsApp`. - Document the current `gen-l10n` limitation with `material_ui` and the `l10n.yaml` header workaround. - Point `GlobalMaterialLocalizations` API links at `material_ui` and explain the `hide` import used by the `add_language` example. material_ui / cupertino_ui breaking-change page: - Add guidance on resolving `ambiguous_import` errors after `dart fix --code=migrate_design_widgets`. - Note that the compatibility bridges are deprecated by design and emit `deprecated_member_use`. - Note that a `CupertinoApp` rendering `material_ui` widgets needs `GlobalMaterialLocalizations.delegates`. - Document `gen-l10n` status, tracked in flutter/flutter#191072 and flutter/flutter#194500. The `l10n.yaml` header workaround in `gen_l10n_example` is kept until the `gen-l10n` fix lands in a stable release. Fixes flutter#14100
There was a problem hiding this comment.
Code Review
This pull request updates the internationalization documentation and examples to reflect the migration to the standalone material_ui and cupertino_ui packages. It adds instructions on resolving ambiguous imports, handling localizations for CupertinoApp, and working around current limitations with the gen-l10n tool (such as using ignore_for_file: deprecated_member_use and manually building the localizations delegates list). It also updates the relevant code examples with docregion tags for documentation excerpts. I have no feedback to provide as the changes are clear, accurate, and follow the repository style guide.
|
Staged preview of the updated docs.flutter.dev site (updated for commit 2c9e1b1): https://flutter-docs-prod--docs-pr14111-i18n-material-ui-3-50-803aztq4.web.app |
- Remove the redundant `flutter pub add flutter_localizations intl` step from initial setup in `ui/internationalization/index.md`, update the `WidgetsApp` note to pass `[GlobalWidgetsLocalizations.delegate]`, and cover both `material_ui` and `cupertino_ui` in the `ambiguous_import` warning. - Clarify the `gen-l10n` English-only fallback behavior, mention `GlobalCupertinoLocalizations.delegates` for Cupertino-only apps, and remind readers to re-run `flutter gen-l10n` after updating `l10n.yaml`. - Align `add_language/lib/main.dart` to `show GlobalWidgetsLocalizations` and link to the `material_ui` localizations README in `flutter/packages`. - Tighten phrasing across both pages for clarity and natural voice.
|
Would you mind taking a look at this PR to fix the issue you submitted, @bkonyi ? Thanks! |
Part of #14100
Updates the internationalization page and the
material_ui/cupertino_uibreaking-change page for Flutter 3.50.Internationalization page (
/ui/internationalization)flutter createhasn't yet been updated to usematerial_uiby default. Existing projects are pointed todart fix --apply --code=migrate_design_widgetsand the migration page.flutter pub add flutter_localizations intlstep from the initial setup section (kept in Add your own localized messages, wheregen-l10nneeds it).as flutter_localizationsprefix import with thematerial_uiimport that the unprefixedGlobalMaterialLocalizations.delegatescode relies on, and warn about theambiguous_importconflict when importingflutter_localizationsalongsidematerial_uiorcupertino_uiwithoutshoworhide.CupertinoApp(including when it uses Material widgets) andWidgetsApp([GlobalWidgetsLocalizations.delegate]withshow GlobalWidgetsLocalizations).gen-l10nsteps explaining thatAppLocalizations.localizationsDelegatesstill uses the deprecatedflutter_localizationsdelegates (causing non-English locales to fail at runtime despite the English-only fallback), with thel10n.yamlheaderworkaround pulled in as a code excerpt.GlobalMaterialLocalizationsAPI links at thematerial_uiAPI docs, point the localization strings README link atflutter/packages'smaterial_uiREADME, remove the unused[language-count]reference, and fix theLocalizationswidget link.show GlobalWidgetsLocalizationsimport used by theadd_languageexample.Breaking-change page (
/release/breaking-changes/material-ui-and-cupertino-ui)ambiguous_importerrors afterdart fix.MaterialUiCompatibilityBridgeandCupertinoUiCompatibilityBridgeare deprecated by design and triggerdeprecated_member_usewarnings.CupertinoAppusingmaterial_uiwidgets needsGlobalMaterialLocalizations.delegates.Examples
add_language/lib/main.dartfromhide GlobalMaterialLocalizationstoshow GlobalWidgetsLocalizationsfor consistency across the docs, and add docregions toadd_language/lib/main.dartandgen_l10n_example/l10n.yamlfor the new excerpts.l10n.yamlheaderworkaround is intentionally kept since [flutter_tools] Support standalone UI packages in gen-l10n flutter#194500 hasn't merged yet. Keeping Update internationalization and material_ui migration docs for Flutter 3.50 #14100 open to track removing it once the fix rolls to stable.Verification
dart run dash_site --site=docs refresh-excerpts: no excerpts needed updating.dart run dash_site --site=docs buildandcheck-link-references: pass.material_ui1.11.1 /cupertino_ui1.1.7 sources and the stableflutter_toolstemplates.