goi18n

package
v0.27.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

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 added in v0.27.0

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

Jump to

Keyboard shortcuts

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