goi18n

package
v0.51.7-beta1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Overview

Internationalization implementation using nicksnyder/go-i18n

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *Config) (localize.Localizer, error)

New creates a new nicksnyder/go-i18n client. You can pass nil to use the pre-configured defaults Or pass a partial config to override some defaults. Default file path: locales Default file format: toml (yaml and json are supported) Default language: English

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

type Goi18n

type Goi18n struct {
	// contains filtered or unexported fields
}

go-i18n implementation

func (*Goi18n) MustLocalize

func (l *Goi18n) MustLocalize(id string, tmplEntries ...*localize.TemplateEntry) string

MustLocalize loads a i18n message from the file system You can pass dynamic values using template entries Examples:

`localizer.MustLocalize("my-message-id", &localize.TemplateEntry{"Name", "Danny"})`

func (*Goi18n) MustLocalizeError

func (l *Goi18n) MustLocalizeError(id string, tmplEntries ...*localize.TemplateEntry) error

MustLocalizeError loads a i18n message from the file system and returns an error Examples:

`err := localizer.MustLocalizeError("my-message-id", &localize.TemplateEntry{"Name", "Danny"}`

func (*Goi18n) MustLocalizeFile

func (l *Goi18n) MustLocalizeFile(files fs.FS, path string) (err error)

read the message file from the file system

func (*Goi18n) MustLocalizePlural

func (l *Goi18n) MustLocalizePlural(id string, pluralCount int, tmplEntries ...*localize.TemplateEntry) string

MustLocalizePlural loads a pluralized i18n message from the file system You can pass dynamic values using template entries Examples:

`localizer.MustLocalizePlural("my-message-id", 2)`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL