i18n

package
v1.100.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MPL-2.0 Imports: 11 Imported by: 84

Documentation

Overview

Package i18n provides internationalization support for applications.

Index

Constants

View Source
const (
	// Extension is the file name extension required on localization files.
	Extension = ".i18n"
)

Variables

View Source
var (
	// Dir is the directory to scan for localization files. This will occur only once, the first time a call to Text()
	// is made. If you do not set this prior to the first call, a directory in the same location as the executable with
	// "_i18n" appended to the executable name (sans any extension) will be used.
	Dir string
	// Language is the language that should be used for text returned from calls to Text(). It is initialized to the
	// result of calling Locale(). You may set this at runtime, forcing a particular language for all subsequent calls
	// to Text().
	Language = Locale()
	// Languages is a slice of languages to fall back to should the one specified in the Language variable not be
	// available. It is initialized to the value of the LANGUAGE environment variable.
	Languages = strings.Split(os.Getenv("LANGUAGE"), ":")
)

Functions

func Locale added in v1.1.4

func Locale() string

Locale returns the value of the LC_ALL environment variable, if set. If not, then it falls back to the value of the LANG environment variable. If that is also not set, then it returns "en_US.UTF-8".

func Text

func Text(text string) string

Text returns a localized version of the text if one exists, or the original text if not.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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