[material_ui, cupertino_ui] Localizations#12119
Conversation
…e class with date time formatting (#29767)
…n the instructions (#30527)
…t of gen_localizations.dart (#29822)
Updating flutter fork
…nd generate one for cupertino english and french (#29824)
Updating flutter fork
…orted languages (#31644)" (#32470) This reverts commit 5c3c680.
…ted languages (#32513)
Corects a bnuch of typeos throuhgout teh Fluter codebsae. Made use of the `misspell` tool: https://github.com/client9/misspell
* Refresh .arb files * Refresh localizations
Updates localizations to match what is now generated. It's unclear what caused the change: it didn't happen because of a flutter PR change, so we're still looking for where the source of the non-determinism is. In the meantime, this will fix the build.
* Sort Localization generation output - When creating locales that were assumed from existing locales, the file that is used is non-deterministic. This adds a sort to the iterator to ensure that the same existing locale is used to generate the assumed locale - When generating material, cupertino and date localizations, the generated getters were not sorted. This introduces an alphabetic sort * remove main.dart.snapshot
No code changes, just comments: I spell-checked all the comments in the repo.
* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
Sorry, this comment posted as incomplete. Updated. |
QuncCccccc
left a comment
There was a problem hiding this comment.
I haven't finished review. Just did a quick look. I'll do another round of review and verify the process to add new strings and export translations from translation console.
| // | ||
| // These classes are constructed by the [getCupertinoTranslation] method at the | ||
| // bottom of this file, and used by the [_GlobalCupertinoLocalizationsDelegate.load] | ||
| // method defined in `cupertino_ui/lib/src/cupertino_localizations.dart`. |
There was a problem hiding this comment.
| // method defined in `cupertino_ui/lib/src/cupertino_localizations.dart`. | |
| // method defined in `cupertino_ui/lib/src/global_cupertino_localizations.dart`. |
| String get showMenuTooltip; | ||
| ``` | ||
| to the localizations class `CupertinoLocalizations`, | ||
| in [`packages/cupertino_ui/lib/src/cupertino_localizations.dart`](https://github.com/flutter/packages/blob/main/packages/cupertino_ui/lib/src/cupertino_localizations.dart); |
There was a problem hiding this comment.
| in [`packages/cupertino_ui/lib/src/cupertino_localizations.dart`](https://github.com/flutter/packages/blob/main/packages/cupertino_ui/lib/src/cupertino_localizations.dart); | |
| in [`packages/cupertino_ui/lib/src/cupertino_localizations.dart`](https://github.com/flutter/packages/blob/main/packages/cupertino_ui/lib/src/localizations.dart); |
| @override | ||
| String aboutListTileTitle(String applicationName) => 'About $applicationName'; | ||
| ``` | ||
| For messages with parameters, do also add the function to `GlobalCupertinoLocalizations` in [`packages/flutter_localizations/lib/src/cupertino_localizations.dart`](https://github.com/flutter/flutter/blob/main/packages/flutter_localizations/lib/src/cupertino_localizations.dart), and add a raw getter as demonstrated below: |
There was a problem hiding this comment.
Should this be
| For messages with parameters, do also add the function to `GlobalCupertinoLocalizations` in [`packages/flutter_localizations/lib/src/cupertino_localizations.dart`](https://github.com/flutter/flutter/blob/main/packages/flutter_localizations/lib/src/cupertino_localizations.dart), and add a raw getter as demonstrated below: | |
| For messages with parameters, do also add the function to `GlobalCupertinoLocalizations` in [`packages/cupertino_ui/lib/src/global_cupertino_localizations.dart`](https://github.com/flutter/packages/blob/main/packages/cupertino_ui/lib/src/global_cupertino_localizations.dart), and add a raw getter as demonstrated below: |
| until they can be translated. | ||
|
|
||
| Finally you need to re-generate | ||
| lib/src/l10n/generated_material_localizations.dart by running: |
There was a problem hiding this comment.
| lib/src/l10n/generated_material_localizations.dart by running: | |
| lib/src/l10n/generated_cupertino_localizations.dart by running: |
| 2. Update the .arb files. Modify the out-of-date English strings in | ||
| `lib/scr/l10n/cupertino_en.arb`. | ||
|
|
||
| You also need to re-generate `lib/src/l10n/localizations.dart` by running: |
There was a problem hiding this comment.
| You also need to re-generate `lib/src/l10n/localizations.dart` by running: | |
| You also need to re-generate `lib/src/l10n/generated_cupertino_localizations.dart` by running: |
| // | ||
| // These classes are constructed by the [getCupertinoTranslation] method at the | ||
| // bottom of this file, and used by the [_GlobalCupertinoLocalizationsDelegate.load] | ||
| // method defined in `flutter_localizations/lib/src/cupertino_localizations.dart`. |
There was a problem hiding this comment.
| // method defined in `flutter_localizations/lib/src/cupertino_localizations.dart`. | |
| // method defined in `cupertino_ui/lib/src/global_cupertino_localizations.dart`. |
|
|
||
| import 'dart:collection'; | ||
|
|
||
| import 'package:material_ui/material_ui.dart'; |
There was a problem hiding this comment.
The generated_material_localizations.dart shows the header should be
| import 'package:material_ui/material_ui.dart'; | |
| import 'package:flutter/widgets.dart'; |
| import 'package:material_ui/material_ui.dart'; | ||
| import 'package:intl/intl.dart' as intl; | ||
|
|
||
| import '../material_localizations.dart'; |
There was a problem hiding this comment.
import '../global_material_localizations.dart';
import '../time.dart';
import '../typography.dart';
| import '../material_localizations.dart'; | ||
|
|
||
| // The classes defined here encode all of the translations found in the | ||
| // `flutter_localizations/lib/src/l10n/*.arb` files. |
There was a problem hiding this comment.
| // `flutter_localizations/lib/src/l10n/*.arb` files. | |
| // `material_ui/lib/src/l10n/*.arb` files. |
| // | ||
| // These classes are constructed by the [getMaterialTranslation] method at the | ||
| // bottom of this file, and used by the [_MaterialLocalizationsDelegate.load] | ||
| // method defined in `flutter_localizations/lib/src/material_localizations.dart`. |
There was a problem hiding this comment.
| // method defined in `flutter_localizations/lib/src/material_localizations.dart`. | |
| // method defined in `material_ui/lib/src/global_material_localizations.dart`. |
There was a problem hiding this comment.
Thank you so much for the attention to detail in your review! I missed so many of these out of date paths and stuff that would have confused our users.
|
Note: To get this to work with the demo app in flutter/flutter#188757, I had to do the following: (as noted in PR description) but also, I had to change: to I originally tried the following, but got this runtime error: |
| @@ -21,17 +21,23 @@ dependencies: | |||
| sdk: flutter | |||
| # This is not unpinned currently. | |||
| # See https://github.com/flutter/flutter/issues/185017 | |||
There was a problem hiding this comment.
Comment should be above material_color_utilities
|
|
||
| // Examples can assume: | ||
| // import 'package:flutter_localizations/flutter_localizations.dart'; | ||
| // import 'package:flutter/material.dart'; |
There was a problem hiding this comment.
Should this comment be updated?
Here as well:
|
|
||
| /// Only used to generate localization strings for the Kannada locale ('kn') because | ||
| /// some of the localized strings contain characters that can crash Emacs on Linux. | ||
| /// See packages/flutter_localizations/lib/src/l10n/README for more information. |
There was a problem hiding this comment.
Maybe: "See packages/flutter_localizations/lib/src/l10n/README in the Flutter SDK for more information" ?
| // replaced by JSON escapes. This is done because some of those strings | ||
| // contain characters that can crash Emacs on Linux. There is more information | ||
| // here: https://github.com/flutter/flutter/issues/36704 and in the README | ||
| // in flutter_localizations/packages/lib/src/l10n. |
There was a problem hiding this comment.
Ditto here - maybe add "in the Flutter SDK"
|
@elliette Good catch, when I tested this I didn't use GlobalCupertinoLocalizations. I think the best way to solve this is the following: import 'package:material_ui/material_ui.dart';
// No flutter_localizations needed.
...
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
...GlobalMaterialLocalizations.delegates,
// No GlobalWidgetsLocalizations needed, because it's included in the above line.
],I'm open to other recommendations but I'll update the description up top with this for now. |
I've added this to my checklist doc and my comms doc.
Yes, I've added this to my checklist doc as well. |
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.
Before
As described in flutter/flutter#188757, a typical localized app like the following would encounter runtime type errors:
After
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/?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.I have moved it to the root of the repo at /script/l10nTODOs
Update l10n README files.Resources
Fixes flutter/flutter#188757