-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Fix gen_date_localizations script and regenerate #124547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix gen_date_localizations script and regenerate #124547
Conversation
| .last; | ||
|
|
||
| final Directory dateSymbolsDirectory = Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'symbols')); | ||
| final List<dynamic> packages = ( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
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? |
|
@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. |
| final Map<String, Object?> packageAsMap = package! as Map<String, Object?>; | ||
| if (packageAsMap['name'] == 'intl') { | ||
| pathToIntl = (packageAsMap['rootUri']! as String).substring(7); | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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时', |
There was a problem hiding this comment.
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())
}
Internal bug: b/256596915
Turns out we need to regenerate date localizations in order for the
intlpackage to be setup properly within Flutter. This PR fixes the script (since it assumes the use of the old.packagesway of handling packages), and regenerates thegenerated_date_localizations.dartfile.