Skip to content

Instantly share code, notes, and snippets.

@sodiboo
Created November 3, 2025 10:39
Show Gist options
  • Select an option

  • Save sodiboo/8e63cda36159474c830f2d409dc02f5e to your computer and use it in GitHub Desktop.

Select an option

Save sodiboo/8e63cda36159474c830f2d409dc02f5e to your computer and use it in GitHub Desktop.
parsing pure-rust-locales and filtering for the good ones
git clone https://github.com/chronotope/pure-rust-locales
cd pure-rust-locales
rustdoc src/lib.rs -Z unstable-options --output-format json
let lib = open doc/lib.json
let items = $lib.index | columns | each {into int} | math max | 0..$in | each {|e| {index: $e, item: ($lib.index | get -o ($e | into string))} } | flatten | each { try { update inner { transpose -d kind content } } catch { {} } } | flatten inner
def expand [] { let $i = $in; let item = $items | get $i; if $item.kind == "use" { $item.content.id | expand | update name $item.content.name } else { $item } }
def transpose_members_map [f] { each { [ $in.name ($in | do $f) ] } | into record }
let locales = $items | get $lib.root | get content.items | each { expand } | where kind == "module" | select name content | update content { get items | each { expand } | transpose_members_map { get content.items | each { expand } | transpose_members_map { get docs | str trim -c "`" } } } | flatten | rename -c {name:index}
$locales | where LC_TIME.D_FMT in ['%F' '"%Y-%m-%d"'] and LC_TIME.T_FMT in ['"%T"' '"%H:%M:%S"' '"%R:%S"'] and LC_NUMERIC.DECIMAL_POINT == '"."'
@sodiboo
Copy link
Author

sodiboo commented Nov 3, 2025

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