]> git.plutz.net Git - invoices/commitdiff
format numbers using localized decimal and thousands separator
authorPaul Hänsch <paul@plutz.net>
Tue, 21 Jan 2025 02:45:05 +0000 (03:45 +0100)
committerPaul Hänsch <paul@plutz.net>
Tue, 21 Jan 2025 02:45:05 +0000 (03:45 +0100)
l10n.sh

diff --git a/l10n.sh b/l10n.sh
index 41d3c46c004ae717bf49b7edfa70466c1e4746d8..9e016b0a8bb6a0ebb5b26b280ac7195073df3247 100755 (executable)
--- a/l10n.sh
+++ b/l10n.sh
@@ -14,3 +14,8 @@ _(){
     *) printf '%s' "$*";;
   esac
 }
+
+num() {
+  { [ "$#" -gt 0 ] && printf '%s\n' "$*" || cat; } \
+  | sed -E ':0 s;\.;d;; s;([0-9])([0-9]{3}[dm]);\1m\2;; t0; y;dm;,.;'
+}