Skip to content

L10n

var (
// GetI18n returns the active I18n instance used by L10n.
// This is a global setting and must be set before calling L10n.GetText or L10n.Text.
GetI18n func() *archmage.I18n
// GetPreferredLanguage returns the preferred language tag used by L10n.
// This is a global setting and must be set before calling L10n.Text.
GetPreferredLanguage func() language.Tag
)

L10n is a localization key that resolves to translated text via the active I18n instance.

type L10n string

GetText returns the translation in the given language. It returns an error if the key is not found. An empty key yields an empty string.

func (l L10n) GetText(lang language.Tag) (string, error)

Text returns the translation in the globally configured preferred language, falling back to the default language if no translation is found, and finally to the key string if neither language has a translation.

func (l L10n) Text() string