i18n

package
v0.0.0-...-c17893f Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type I18n

type I18n struct {
	Provider Provider `inject:""`
	Locales  map[string]map[string]string
	Logger   *logging.Logger `inject:""`
}

I18n i18n helper

func (*I18n) Exist

func (p *I18n) Exist(lang string) bool

Exist is lang exist?

func (*I18n) Items

func (p *I18n) Items(lng *language.Tag) map[string]interface{}

Items list all items

func (*I18n) Load

func (p *I18n) Load(dir string)

Load load locales from filesystem

func (*I18n) T

func (p *I18n) T(lng *language.Tag, code string, args ...interface{}) string

T translate by lang tag

func (*I18n) Ts

func (p *I18n) Ts(lng string, code string, args ...interface{}) string

Ts translate by lang

type Locale

type Locale struct {
	gorm.Model
	Lang    string `gorm:"not null;type:varchar(8);index"`
	Code    string `gorm:"not null;index;type:VARCHAR(255)"`
	Message string `gorm:"not null;type:varchar(800)"`
}

Locale locale model

type OrmProvider

type OrmProvider struct {
	Db     *gorm.DB        `inject:""`
	Logger *logging.Logger `inject:""`
}

OrmProvider db provider

func (*OrmProvider) Del

func (p *OrmProvider) Del(lng *language.Tag, code string)

Del del locale

func (*OrmProvider) Get

func (p *OrmProvider) Get(lng *language.Tag, code string) string

Get get locale

func (*OrmProvider) Keys

func (p *OrmProvider) Keys(lng *language.Tag) []string

Keys list locale keys

func (*OrmProvider) Set

func (p *OrmProvider) Set(lng *language.Tag, code, message string)

Set set locale

type Provider

type Provider interface {
	Set(lang *language.Tag, code, message string)
	Get(lang *language.Tag, code string) string
	Del(lang *language.Tag, code string)
	Keys(lang *language.Tag) []string
}

Provider i18n provider

Jump to

Keyboard shortcuts

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