Repository navigation
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.
here and elsewhere: use Object? instead of dynamic. dynamic turns off the type system and makes it easy to miss some bugs.
| 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.
What does the magic number 7 mean here?
There was a problem hiding this comment.
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.
Should this use Uri.parse(uriPath).toFilePath() to be a little more robust then?
|
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.
add a break; to the if clause? Once you have found intl there is no reason to keep going in the for loop, right?
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.
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.