Skip to content

Instantly share code, notes, and snippets.

@koral--
Created November 28, 2023 11:43
Show Gist options
  • Save koral--/c8e01edd5675eb2e838820f5159a19c9 to your computer and use it in GitHub Desktop.
Save koral--/c8e01edd5675eb2e838820f5159a19c9 to your computer and use it in GitHub Desktop.
XML parser
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