aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xdatefmt19
-rwxr-xr-xgetfmt37
2 files changed, 37 insertions, 19 deletions
diff --git a/datefmt b/datefmt
deleted file mode 100755
index 747b47a..0000000
--- a/datefmt
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-url()
-{
- echo "https://raw.githubusercontent.com/unicode-org/cldr-json/refs/heads/main/cldr-json/cldr-dates-full/main/$1/ca-gregorian.json"
-}
-
-if [ $# -lt 1 ]
-then
- echo "Usage: datefmt locale..." >&2
- exit 1
-fi
-
-for l in "$@"
-do
- [ $# -gt 1 ] && printf '%s:\t' "$l"
- curl -s "$(url "$l")" | jq -r --arg l "$l" \
- '.main.[$l].dates.calendars.gregorian.dateFormats.short'
-done
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