Created
November 28, 2023 11:43
-
-
Save koral--/c8e01edd5675eb2e838820f5159a19c9 to your computer and use it in GitHub Desktop.
XML parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map.fromEntries(XmlDocument.parse( | |
await Resource('package:plural_lint/src/cldr/plurals.xml') // 1 | |
.readAsString(encoding: utf8)) | |
.xpath('/supplementalData/plurals[@type="cardinal"]/pluralRules') // 2 | |
.map((item) => item | |
.xpath('@locales') | |
.first | |
.value! // 3 | |
.split(' ') // 4 | |
.map((locale) => MapEntry( | |
locale, | |
item | |
.xpath('pluralRule/@count') // 5 | |
.map((e) => e.value!) | |
.toList(growable: false))) // 6 | |
) | |
.expand((item) => item)); // 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment