locale

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const RAW = "raw"

Variables

View Source
var (
	ErrNoProvider            = errors.New("config: empty config-name or config-provider is nil")
	ErrUnknownProvider       = errors.New("config: unknown config-provider %q")
	ErrProviderAlreadyExists = errors.New("config: config-provider %#v is already registered")
)

Error messages.

Functions

func GoDateFormatFromHumanFormat

func GoDateFormatFromHumanFormat(f string) (string, error)

func Register

func Register(provider string, fn provider) error

Register the config provider. This should be called in the init() of the providers. If the config provider/name is empty or is already registered, an error will return.

func Reload

func Reload() (err error)

func SetBundle

func SetBundle(p BundleI) (err error)

Types

type BundleI

type BundleI interface {
	Bundle() (*i18n.Bundle, error)
	AddSource(interface{}) error
	DefaultMessage(id string) *i18n.Message
	DefaultLanguage() language.Tag
	SetDefaultLanguage(language.Tag)
}

func NewBundle

func NewBundle(provider string, defaultLanguage string) (BundleI, error)

type DateFormat

type DateFormat struct {
	GoFormat    string
	HumanFormat string
}

func DateFormats

func DateFormats() []DateFormat

type LocalizerI

type LocalizerI interface {
	Translate(messageID string, template ...map[string]interface{}) (string, error)
	TranslatePlural(messageID string, pluralCount interface{}, template ...map[string]interface{}) (string, error)
}

func NewLocalizer

func NewLocalizer(lang ...string) (LocalizerI, error)

CreateLocalizer create localizer object to generate text messages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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