Documentation ¶
Index ¶
- func GetCurrentLanguage() string
- func GetEnableLanguage() string
- func LT(locale, content string) string
- func LTf(locale, format string, values ...interface{}) string
- func LocaleLoadHook(db *gorm.DB)
- func LocaleUpdateHook(db *gorm.DB)
- func SetCurrentLanguage(locale string)
- func Start()
- func T(content string) string
- func Tf(format string, values ...interface{}) string
- type I18nEnabled
- type I18nFactory
- type I18nPropertiesEnabled
- type LocaleFieldValue
- type Manager
- func (m *Manager) GetContent(key string) interface{}
- func (m *Manager) LT(locale, content string) string
- func (m *Manager) LTf(locale, format string, values ...interface{}) string
- func (m *Manager) LocaleTranslate(lang, content string) string
- func (m *Manager) LocaleTranslateFormat(locale, format string, values ...interface{}) string
- func (m *Manager) SetDelimiters(left, right string)
- func (m *Manager) SetLanguage(language string)
- func (m *Manager) SetPath(path string) error
- func (m *Manager) T(content string) string
- func (m *Manager) Translate(content string) string
- func (m *Manager) TranslateFormat(format string, values ...interface{}) string
- type Options
- type Translator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCurrentLanguage ¶ added in v0.0.33
func GetCurrentLanguage() string
func GetEnableLanguage ¶ added in v0.0.38
func GetEnableLanguage() string
func SetCurrentLanguage ¶ added in v0.0.45
func SetCurrentLanguage(locale string)
Types ¶
type I18nEnabled ¶ added in v0.0.28
type I18nEnabled struct {
LocaleFields []*LocaleFieldValue `gorm:"-" json:"-"`
}
type I18nFactory ¶
type I18nFactory struct {
Translator Translator `inject:"translator"`
}
type I18nPropertiesEnabled ¶ added in v0.0.46
type I18nPropertiesEnabled interface {
I18nProperties() string
}
type LocaleFieldValue ¶
type LocaleFieldValue struct { EntityName string `gorm:"column:entity_name;primaryKey" json:"entityName"` EntityId string `gorm:"column:entity_id;primaryKey" json:"entityId"` Name string `gorm:"column:name;primaryKey" json:"name"` Locale string `gorm:"column:locale;default:en;primaryKey" json:"locale"` Value string `gorm:"column:value" json:"value"` }
type Manager ¶ added in v0.0.33
type Manager struct {
// contains filtered or unexported fields
}
Manager for i18n contents, it is concurrent safe, supporting hot reload.
func New ¶ added in v0.0.33
New creates and returns a new i18n manager. The optional parameter `option` specifies the custom options for i18n manager. It uses a default one if it's not passed.
func (*Manager) GetContent ¶ added in v0.0.33
GetContent retrieves and returns the configured content for given key and specified language. It returns an empty string if not found.
func (*Manager) LocaleTranslate ¶ added in v0.0.33
func (*Manager) LocaleTranslateFormat ¶ added in v0.0.33
TranslateFormat translates, formats and returns the `format` with configured language and given `values`.
func (*Manager) SetDelimiters ¶ added in v0.0.33
SetDelimiters sets the delimiters for translator.
func (*Manager) SetLanguage ¶ added in v0.0.33
SetLanguage sets the language for translator.
func (*Manager) Translate ¶ added in v0.0.33
Translate translates `content` with configured language.
func (*Manager) TranslateFormat ¶ added in v0.0.33
TranslateFormat translates, formats and returns the `format` with configured language and given `values`.
type Options ¶ added in v0.0.33
type Options struct { Path string // I18n files storage path. Language string // Default local language. Delimiters []string // Delimiters for variable parsing. }
Options is used for i18n object configuration.
type Translator ¶
type Translator interface { StoreTranslations(translations []*LocaleFieldValue) LoadTranslations(locale, entityName string, entityId ...string) map[string][]*LocaleFieldValue }