Documentation ¶
Index ¶
- Constants
- Variables
- func DeserializeFile(filename string) (map[string]*Element, error)
- func RegisterDeserializer(extension string, deserializer Deserializer)
- type Bundle
- func NewBundleFromDir(defLang interface{}, path string) (*Bundle, error)
- func NewBundleFromFiles(defLang interface{}, files []string) (*Bundle, error)
- func NewBundleFromLang(defLang interface{}) (*Bundle, error)
- func NewCustomBundle(defLang string, deserializers *map[string]Deserializer) (*Bundle, error)
- func NewCustomBundleFromTag(defTag language.Tag, deserializers *map[string]Deserializer) *Bundle
- func (instance *Bundle) AddElement(rawLang string, path string, elem *Element)
- func (instance *Bundle) Deserializers() []string
- func (instance *Bundle) Get(lang string, path string, data ...interface{}) (string, error)
- func (instance *Bundle) GetDictionary(rawLang string) (map[string]*Element, error)
- func (instance *Bundle) GetDictionaryByTag(tag language.Tag) (map[string]*Element, error)
- func (instance *Bundle) GetElement(lang string, path string) (*Element, error)
- func (instance *Bundle) GetWithPlural(lang string, path string, pluralFields []string, data ...interface{}) (string, error)
- func (instance *Bundle) GetWithPluralValue(lang string, path string, value float64, data ...interface{}) (string, error)
- func (instance *Bundle) LoadAll(dirName string) error
- func (instance *Bundle) LoadFile(file string) error
- func (instance *Bundle) LoadFiles(files []string) error
- func (instance *Bundle) Renderer() I18nRenderer
- func (instance *Bundle) SetRenderer(renderer I18nRenderer)
- func (instance *Bundle) String() string
- type Deserializer
- type Element
- type I18NHelper
- type I18nRenderer
- type Localizer
- type Renderer
Constants ¶
View Source
const ( SUFFIX_SEP = "_" SUFFIX_LENGHT = "_length" SUFFIX_INDEX = "_index" )
Variables ¶
View Source
var ( LanguageNotSupportedError = errors.New("language_not_supported") DeserializerNotRegisteredError = errors.New("deserializer_not_registered") ResourceNotFoundError = errors.New("resource_not_found") )
View Source
var (
PLURAL_FIELDS = []string{"value", "count", "values", "qty", "length", "len", "size", "num"}
)
Functions ¶
func RegisterDeserializer ¶
func RegisterDeserializer(extension string, deserializer Deserializer)
Types ¶
type Bundle ¶
type Bundle struct { Strictly bool // must load data or go panic IgnoreUnknownDeserializers bool // contains filtered or unexported fields }
func NewBundleFromDir ¶
func NewBundleFromFiles ¶
func NewBundleFromLang ¶
func NewCustomBundle ¶
func NewCustomBundle(defLang string, deserializers *map[string]Deserializer) (*Bundle, error)
func NewCustomBundleFromTag ¶
func NewCustomBundleFromTag(defTag language.Tag, deserializers *map[string]Deserializer) *Bundle
func (*Bundle) AddElement ¶
func (*Bundle) Deserializers ¶
func (*Bundle) GetDictionary ¶
func (*Bundle) GetDictionaryByTag ¶
func (*Bundle) GetElement ¶
func (*Bundle) GetWithPlural ¶
func (*Bundle) GetWithPluralValue ¶
func (*Bundle) Renderer ¶
func (instance *Bundle) Renderer() I18nRenderer
func (*Bundle) SetRenderer ¶
func (instance *Bundle) SetRenderer(renderer I18nRenderer)
type Element ¶
type Element struct { Zero string `json:"zero"` One string `json:"one"` Two string `json:"two"` Other string `json:"other"` }
func NewElementFromMap ¶
func NewElementFromString ¶
func (*Element) PluralValueWithFields ¶
type I18NHelper ¶
type I18NHelper struct { }
var I18N *I18NHelper
func (*I18NHelper) NewLocalizer ¶
func (instance *I18NHelper) NewLocalizer(args ...interface{}) (localizer *Localizer, err error)
type I18nRenderer ¶
type Localizer ¶
type Localizer struct {
// contains filtered or unexported fields
}
func NewLocalizer ¶
func (*Localizer) Renderer ¶
func (instance *Localizer) Renderer() I18nRenderer
func (*Localizer) SetRenderer ¶
func (instance *Localizer) SetRenderer(renderer I18nRenderer)
Click to show internal directories.
Click to hide internal directories.