i18n

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: BSD-3-Clause, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultLocaleRoot is the root dir of locales, usually is
	// "{Prefix}/share/locale".
	DefaultLocaleRoot = "/opt/go-i18n/share/locale"
)

Functions

This section is empty.

Types

type Locale

type Locale struct {
	// Embedding methods from gotext's Locale
	*gotext.Locale
	// contains filtered or unexported fields
}

func GetLocale

func GetLocale(lang string) *Locale

GetLocale returns locale for the specific language.

func Setup

func Setup(rootDir, domain string) *Locale

Setup rootDir and domain for locale, and will return locale for default language.

func (Locale) L_

func (v Locale) L_(str string) string

* Mark i18n strings using the following wrapper: * * L_(), L_D(), L_C(), L_DC(), * Q_(), Q_D(), Q_C(), Q_DC(), * and N_().

func (Locale) L_C

func (v Locale) L_C(str, ctx string) string

func (Locale) L_D

func (v Locale) L_D(dom, str string) string

func (Locale) L_DC

func (v Locale) L_DC(dom, str, ctx string) string

func (Locale) Lang

func (v Locale) Lang() string

func (Locale) LocaleName

func (v Locale) LocaleName() string

func (Locale) N_

func (v Locale) N_(str string) string

* Mark for translation, but not expand immediately. Usually save the * raw string in a variable, and expand the variable in runtime. E.g. * * prompt := []string { i18n.N_("prompt1"), i18n.N_("prompt2"), ... } * fmt.Print( i18n.L_(prompt[1]) )

func (Locale) Q_

func (v Locale) Q_(str, plural string, n int) string

func (Locale) Q_C

func (v Locale) Q_C(str, plural string, n int, ctx string) string

func (Locale) Q_D

func (v Locale) Q_D(dom, str, plural string, n int) string

func (Locale) Q_DC

func (v Locale) Q_DC(dom, str, plural string, n int, ctx string) string

Jump to

Keyboard shortcuts

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