Skip to content

Conversation

@thkim1011
Copy link
Contributor

Internal bug: b/256596915

Turns out we need to regenerate date localizations in order for the intl package to be setup properly within Flutter. This PR fixes the script (since it assumes the use of the old .packages way of handling packages), and regenerates the generated_date_localizations.dart file.

@flutter-dashboard flutter-dashboard bot added a: internationalization Supporting other languages or locales. (aka i18n) f: material design flutter/packages/flutter/material repository. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Apr 10, 2023
.last;

final Directory dateSymbolsDirectory = Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'symbols'));
final List<dynamic> packages = (
Copy link
Member

Choose a reason for hiding this comment

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

here and elsewhere: use Object? instead of dynamic. dynamic turns off the type system and makes it easy to miss some bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

for (final dynamic package in packages) {
final Map<String, dynamic> packageAsMap = package as Map<String, dynamic>;
if (packageAsMap['name'] == 'intl') {
pathToIntl = (packageAsMap['rootUri'] as String).substring(7);
Copy link
Member

Choose a reason for hiding this comment

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

What does the magic number 7 mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah so the uris in package_config.json are formatted with file:// prepended to each url. I couldn't figure out a better way to remove it but let me know if you have better ideas.

Copy link
Member

Choose a reason for hiding this comment

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

Should this use Uri.parse(uriPath).toFilePath() to be a little more robust then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@goderbauer
Copy link
Member

Thanks for fixing the script!

Can we add a test that reminds us to re-generate these whenever we add a new locale? Maybe we should have a test that runs the script on CI and compares that the output matches what's currently checked in? That would also avoid that the script bit-rots and gets out of date.

Also, does this need to be cherry-picked into the 3.10 release since #124094 probably made it into that release?

@thkim1011
Copy link
Contributor Author

@goderbauer I'll make an issue to keep track of this (#124550), but I'd like to get this PR merged in first since it's blocking an internal team.

@thkim1011 thkim1011 requested a review from goderbauer April 10, 2023 22:31
final Map<String, Object?> packageAsMap = package! as Map<String, Object?>;
if (packageAsMap['name'] == 'intl') {
pathToIntl = (packageAsMap['rootUri']! as String).substring(7);
}
Copy link
Member

Choose a reason for hiding this comment

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

add a break; to the if clause? Once you have found intl there is no reason to keep going in the for loop, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@thkim1011 thkim1011 added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 11, 2023
@thkim1011 thkim1011 merged commit c0c5901 into flutter:master Apr 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 12, 2023
exaby73 pushed a commit to exaby73/flutter_nevercode that referenced this pull request Apr 17, 2023
Internal bug: b/256596915

Turns out we need to regenerate date localizations in order for the
`intl` package to be setup properly within Flutter. This PR fixes the
script (since it assumes the use of the old `.packages` way of handling
packages), and regenerates the `generated_date_localizations.dart` file.
'jmv': 'v ah:mm',
'jmz': 'z ah:mm',
'jz': 'zah时',
'j': 'H时',

Choose a reason for hiding this comment

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

Why remove the pattern a, it will caused the localization AMPMS, Does it means need to adaptor the origin logical by append an extra patterns for it? such as

    if (!alwaysUse24HourFormatValue) {
      DateFormat.yMd('zh').addPattern('a', '').add_jm().format(DateTime.now())
    }

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

Labels

a: internationalization Supporting other languages or locales. (aka i18n) autosubmit Merge PR when tree becomes green via auto submit App c: contributor-productivity Team-specific productivity, code health, technical debt. f: material design flutter/packages/flutter/material repository.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants