aboutsummaryrefslogtreecommitdiffhomepage
path: root/getfmt
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-07-23 19:58:53 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-07-23 19:58:53 +0200
commit5f1bd49cfef5852bbd539754fb31e8adada29ef3 (patch)
treebc1991de9f017e0e4133522278cceccea691f19c /getfmt
parente167221e49e59df0b62c0ee5b27ead2043c58571 (diff)
Replace datefmt with getfmt
Diffstat (limited to 'getfmt')
-rwxr-xr-xgetfmt37
1 files changed, 37 insertions, 0 deletions
diff --git a/getfmt b/getfmt
new file mode 100755
index 0000000..a8143a2
--- /dev/null
+++ b/getfmt
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-numbers-full/main/$1/numbers.json
+
+usage()
+{
+ echo "Usage: getfmt currency|date|number locale..." >&2
+ exit 1
+}
+
+[ $# -lt 2 ] && usage
+
+mode="$1"
+shift
+
+case "$mode" in
+currency)
+ url='https://raw.githubusercontent.com/unicode-org/cldr-json/refs/heads/main/cldr-json/cldr-numbers-full/main/$l/numbers.json'
+ qry='.main.[$l].numbers.["currencyFormats-numberSystem-latn"].standard'
+ ;;
+date)
+ url='https://raw.githubusercontent.com/unicode-org/cldr-json/refs/heads/main/cldr-json/cldr-dates-full/main/$l/ca-gregorian.json'
+ qry='.main.[$l].dates.calendars.gregorian.dateFormats.short'
+ ;;
+number)
+ url='https://raw.githubusercontent.com/unicode-org/cldr-json/refs/heads/main/cldr-json/cldr-numbers-full/main/$l/numbers.json'
+ qry='.main.[$l].numbers.["decimalFormats-numberSystem-latn"].standard'
+ ;;
+*)
+ usage
+esac
+
+for l in "$@"
+do
+ [ $# -gt 1 ] && printf '%s:\t' "$l"
+ curl -s "$(eval echo "$url")" | jq -r --arg l "$l" "$qry"
+done \ No newline at end of file