From: Paul Hänsch Date: Tue, 21 Jan 2025 02:45:05 +0000 (+0100) Subject: format numbers using localized decimal and thousands separator X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=5e775c74eb35f87af0aee872e5111b918bb67ee5;p=invoices format numbers using localized decimal and thousands separator --- diff --git a/l10n.sh b/l10n.sh index 41d3c46..9e016b0 100755 --- 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;,.;' +}