icu

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 13 Imported by: 1

README

icu

Documentation

Index

Constants

View Source
const (
	HeaderAcceptLanguage = "Accept-Language"
)
View Source
const (
	TagEn = "en"
)

Variables

This section is empty.

Functions

func Translate

func Translate(tag Tag, msg MessageFormat, ps ...Parameter) (string, error)

Types

type Bundle

type Bundle struct {
	// contains filtered or unexported fields
}

func NewBundle

func NewBundle(directory string, defaultTag Tag) *Bundle

func (*Bundle) TranslatorForRequest

func (b *Bundle) TranslatorForRequest(r *http.Request) Translator

func (*Bundle) TranslatorForTag

func (b *Bundle) TranslatorForTag(tag Tag) Translator

type HierachicalTranslator

type HierachicalTranslator struct {
	Base         Translator
	Tag          Tag
	Translations map[string]MessageFormat
}

func NewHierachicalTranslator

func NewHierachicalTranslator() *HierachicalTranslator

func (*HierachicalTranslator) IsRoot

func (t *HierachicalTranslator) IsRoot() bool

func (*HierachicalTranslator) Translate

func (t *HierachicalTranslator) Translate(key string, ps ...Parameter) string

type MessageFormat

type MessageFormat string

func (MessageFormat) String

func (m MessageFormat) String() string

func (MessageFormat) Translate

func (m MessageFormat) Translate(tag Tag, ps ...Parameter) (string, error)

type Parameter

type Parameter struct {
	Name  string
	Value interface{}
}

func P

func P(name string, value interface{}) Parameter

type Parameters

type Parameters []Parameter

func ParametersFrom

func ParametersFrom(v interface{}) Parameters

func (Parameters) Len

func (ps Parameters) Len() int

func (Parameters) Less

func (ps Parameters) Less(i, j int) bool

func (Parameters) Swap

func (ps Parameters) Swap(i, j int)

type Range

type Range struct {
	Tag     Tag
	Quality float64
}

type Ranges

type Ranges []Range

func (Ranges) Len

func (a Ranges) Len() int

func (Ranges) Less

func (a Ranges) Less(i, j int) bool

func (Ranges) Swap

func (a Ranges) Swap(i, j int)

type Specification

type Specification string

func ExtractSpecification

func ExtractSpecification(r *http.Request) Specification

func (Specification) Ranges

func (s Specification) Ranges() Ranges

func (Specification) Tag

func (s Specification) Tag() Tag

type Tag

type Tag string

type Translator

type Translator interface {
	Translate(key string, ps ...Parameter) string
}

type TranslatorFunc

type TranslatorFunc func(key string, ps ...Parameter) string

func (TranslatorFunc) Translate

func (f TranslatorFunc) Translate(key string, ps ...Parameter) string

Jump to

Keyboard shortcuts

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