Gopher

lang

Lang is Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

lang.FormatAccounting  

(precision any) → string

FormatAccounting returns the currency representation of number for the given currency and precision for the current language in accounting notation.

The return value is formatted with at least two decimal places.

Examples

{{ 512.5032 | lang.FormatAccounting 2 "NOK" }}
NOK512.50

lang.FormatCurrency  

(precision any) → string

FormatCurrency returns the currency representation of number for the given currency and precision for the current language.

The return value is formatted with at least two decimal places.

Examples

{{ 512.5032 | lang.FormatCurrency 2 "USD" }}
$512.50

lang.FormatNumber  

(precision any) → string

FormatNumber formats number with the given precision for the current language.

Examples

{{ 512.5032 | lang.FormatNumber 2 }}
512.50

lang.FormatNumberCustom  

(precision any, options …any) → string

FormatNumberCustom formats a number with the given precision using the negative, decimal, and grouping options. The options parameter is a string consisting of <negative> <decimal> <grouping>. The default options value is - . ,.

Note that numbers are rounded up at 5 or greater. So, with precision set to 0, 1.5 becomes 2, and 1.4 becomes 1.

For a simpler function that adapts to the current language, see FormatNumber.

Examples

{{ lang.FormatNumberCustom 2 12345.6789 }}
12,345.68
{{ lang.FormatNumberCustom 2 12345.6789 "- , ." }}
12.345,68
{{ lang.FormatNumberCustom 6 -12345.6789 "- ." }}
-12345.678900
{{ lang.FormatNumberCustom 0 -12345.6789 "- . ," }}
-12,346
{{ -98765.4321 | lang.FormatNumberCustom 2 }}
-98,765.43

lang.FormatPercent  

(precision any) → string

FormatPercent formats number with the given precision for the current language. Note that the number is assumed to be a percentage.

Examples

{{ 512.5032 | lang.FormatPercent 2 }}
512.50%

lang.Merge  

(p2 any) → any

Merge creates a union of pages from two languages.

lang.Translate  

(id any, args …any) → string

Translate returns a translated string for id.

Aliases: i18n, T