Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Catalog ¶
type Catalog interface { Gettext(msgid string) string NGettext(msgid string, msgid_plural string, n uint32) string }
Catalog of translations for a given locale.
type PathResolver ¶
PathResolver resolves a path to a mo file
type Translations ¶
type Translations struct {
// contains filtered or unexported fields
}
Translations holds the translations in the different locales your app supports. Use NewTranslations to create an instance.
func NewTranslations ¶
func NewTranslations(root string, domain string, resolver PathResolver) Translations
NewTranslations is the main entry point for gogettext. Use this to set up the locales for your app. root is the root of your locale folder, domain the domain you want to load and resolver a function that resolves mo file paths. If your structure is <root>/<locale>/LC_MESSAGES/<domain>.mo, you can use DefaultResolver.
func (Translations) Locale ¶
func (t Translations) Locale(locale string) Catalog
Locale returns the catalog translations for a given Locale. If the given locale is not available, a NullCatalog is returned.
func (Translations) Preload ¶
func (t Translations) Preload(locales ...string)
Preload a list of locales (if they're available). This is useful if you want to limit IO to a specific time in your app, for example startup. Subsequent calls to Preload or Locale using a locale given here will not do any IO.