locale

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Localizer *i18n.Localizer

global variable to keep localizer object used to translate everything in application

View Source
var T = func(messageID string, template interface{}) string {

	if Localizer == nil {
		SetLanguage("")
	}

	msg := Localizer.MustLocalize(&i18n.LocalizeConfig{
		MessageID:    messageID,
		TemplateData: template})
	return msg
}

One of 2 main methods to translate message ID text, using format functionality based on template interface.

View Source
var TP = func(messageID string, template interface{}, pluralCount interface{}) string {

	if Localizer == nil {
		SetLanguage("")
	}

	msg := Localizer.MustLocalize(&i18n.LocalizeConfig{
		MessageID:    messageID,
		TemplateData: template,
		PluralCount:  pluralCount})
	return msg
}

One of 2 main methods to translate message ID text, using format functionality based on template interface. Extra functionality allow to control plural form behavior.

Functions

func SetLanguage

func SetLanguage(lang string)

SetLanguage set up language globally for application localization.

Types

This section is empty.

Source Files

  • common.go
  • localization.go

Jump to

Keyboard shortcuts

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