From e4fbb05cc51ac1eb409808c79fc4527eec881195 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 2 Aug 2025 01:18:13 +0200 Subject: Add support for formatting percentages --- doc/i18n.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/i18n.md b/doc/i18n.md index b7de2dc..dcb5727 100644 --- a/doc/i18n.md +++ b/doc/i18n.md @@ -92,14 +92,15 @@ follows: The following character codes are available with the following behaviour: -| Code | Mnemonic | Description | -| ---- | ------------------ | ----------------------------------------------------------- | -| `e` | \[e]mail | inserts a link to an email address | -| `E` | \[E]nd | inserts closing-tags for the comma-separated HTML tags | -| `l` | \[l]ink (internal) | links to an internal page | -| `L` | \[L]ink (external) | links to an external page | -| `m` | \[m]onetary | formats the given `int` or `float64` as an amount of Euros. | -| `r` | \[r]aw | inserts the given string verbatim without HTML escaping | +| Code | Mnemonic | Description | +| ---- | ------------------ | ---------------------------------------------------------- | +| `e` | \[e]mail | inserts a link to an email address | +| `E` | \[E]nd | inserts closing-tags for the comma-separated HTML tags | +| `l` | \[l]ink (internal) | links to an internal page | +| `L` | \[L]ink (external) | links to an external page | +| `m` | \[m]onetary | formats the given `int` or `float64` as an amount of Euros | +| `p` | \[p]ercentage | formats the given `int` or `float64` as a percentage | +| `r` | \[r]aw | inserts the given string verbatim without HTML escaping | ```html @@ -121,11 +122,16 @@ The following character codes are available with the following behaviour:

{{ .Get "{1:m} and {1.00:m}" (map "1" 1 "1.00" 1.00) }}

+ + + +

{{ .Get "The beer is {5:p} alcohol, or really {4.5:p}" + (map "5" 5 "4.5" 4.5) }}

``` Some additional notes: - The `-` name is special. `{-:E}` inserts ``. This exists because of how often you need to do this. -- The `m` character code won’t include decimals when the argument is an - integer, and will include the decimals when the argument is a - floating-point number. \ No newline at end of file +- The `p` and `m` character codes won’t include decimals when the + argument is an integer, and will include the decimals when the argument + is a floating-point number. \ No newline at end of file -- cgit v1.2.3