package lang
import "github.com/gohugoio/hugo/tpl/lang"
Package lang provides template functions for content internationalization.
Index ¶
- type Namespace
- func New(deps *deps.Deps, translator locales.Translator) *Namespace
- func (ns *Namespace) FormatAccounting(precision, currency, number interface{}) (string, error)
- func (ns *Namespace) FormatCurrency(precision, currency, number interface{}) (string, error)
- func (ns *Namespace) FormatNumber(precision, number interface{}) (string, error)
- func (ns *Namespace) FormatNumberCustom(precision, number interface{}, options ...interface{}) (string, error)
- func (ns *Namespace) FormatPercent(precision, number interface{}) (string, error)
- func (ns *Namespace) Merge(p2, p1 interface{}) (interface{}, error)
- func (ns *Namespace) NumFmt(precision, number interface{}, options ...interface{}) (string, error)
- func (ns *Namespace) Translate(id interface{}, args ...interface{}) (string, error)
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "lang" namespace.
func New ¶
func New(deps *deps.Deps, translator locales.Translator) *Namespace
New returns a new instance of the lang-namespaced template functions.
func (*Namespace) FormatAccounting ¶
FormatAccounting returns the currency reprecentation of number for the given currency and precision for the current language in accounting notation.
func (*Namespace) FormatCurrency ¶
FormatCurrency returns the currency reprecentation of number for the given currency and precision for the current language.
func (*Namespace) FormatNumber ¶
FormatNumber formats number with the given precision for the current language.
func (*Namespace) FormatNumberCustom ¶
func (ns *Namespace) FormatNumberCustom(precision, number interface{}, options ...interface{}) (string, error)
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 FormatNumberCustom.
func (*Namespace) FormatPercent ¶
FormatPercent formats number with the given precision for the current language. Note that the number is assumed to be a percentage.
func (*Namespace) Merge ¶
Merge creates a union of pages from two languages.
func (*Namespace) NumFmt ¶
NumFmt is deprecated, use FormatNumberCustom. We renamed this in Hugo 0.87. Deprecated: Use FormatNumberCustom
func (*Namespace) Translate ¶
Translate returns a translated string for id.
Source Files ¶
- Version
- v0.88.0
- Published
- Sep 2, 2021
- Platform
- darwin/amd64
- Imports
- 11 packages
- Last checked
- 7 minutes ago –
Tools for package owners.