Documentation ¶
Overview ¶
stgn ...
Index ¶
- func Initialize(cfg *Config)
- func RegisterCache(c Cache)
- func RegisterSource(name, version string, sources []ComponentMsgs)
- func SetHTTPHeaders(h map[string]string) error
- func SetLogger(l Logger)
- type Cache
- type ComponentMsgs
- type Config
- type Logger
- type MapComponentMsgs
- func (d *MapComponentMsgs) Clone() ComponentMsgs
- func (d *MapComponentMsgs) Component() string
- func (d *MapComponentMsgs) Get(key string) (value string, found bool)
- func (d *MapComponentMsgs) Locale() string
- func (d *MapComponentMsgs) Range(f func(key, value string) bool)
- func (d *MapComponentMsgs) Set(key, value string)
- func (d *MapComponentMsgs) Size() int
- type Translation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCache ¶
func RegisterCache(c Cache)
RegisterCache Register cache implementation. There is a default implementation
func RegisterSource ¶
func RegisterSource(name, version string, sources []ComponentMsgs)
RegisterSource is the way sending source strings to Singleton client programmatically
func SetHTTPHeaders ¶
SetHTTPHeaders Set customized HTTP headers
Types ¶
type Cache ¶
type Cache interface { // Get Get(key interface{}) (value interface{}, found bool) // Set Set(key interface{}, value interface{}) }
Cache the interface of Cache
type ComponentMsgs ¶
type ComponentMsgs interface { // Get Get a message by key Get(key string) (value string, found bool) Set(key, value string) Component() string Locale() string Size() int Range(func(key, value string) bool) Clone() ComponentMsgs }
ComponentMsgs The interface of a component's messages
type Config ¶
type Config struct { ServerURL string `json:"online_service_url"` LocalBundles string `json:"offline_resources_base_url"` LocalSourceBundle string `json:"source_bundle"` DefaultLocale string `json:"default_locale"` SourceLocale string `json:"source_locale"` }
Config Singleton configuration
func LoadConfig ¶
LoadConfig Create a new Singleton configuration instance
type Logger ¶
type Logger interface { Debug(message string) Info(message string) Warn(message string) Error(message string) }
Logger The logger interface
type MapComponentMsgs ¶
type MapComponentMsgs struct {
// contains filtered or unexported fields
}
MapComponentMsgs is for a ComponentMsgs containing map
func NewMapComponentMsgs ¶
func NewMapComponentMsgs(messages map[string]string, locale, component string) *MapComponentMsgs
NewMapComponentMsgs is to create a new ComponentMsgs easily
func (*MapComponentMsgs) Clone ¶
func (d *MapComponentMsgs) Clone() ComponentMsgs
Clone the component
func (*MapComponentMsgs) Component ¶
func (d *MapComponentMsgs) Component() string
Component returns the component name
func (*MapComponentMsgs) Get ¶
func (d *MapComponentMsgs) Get(key string) (value string, found bool)
Get returns a message by key
func (*MapComponentMsgs) Locale ¶
func (d *MapComponentMsgs) Locale() string
Locale returns the locale of component
func (*MapComponentMsgs) Range ¶
func (d *MapComponentMsgs) Range(f func(key, value string) bool)
Range traverses the messages
func (*MapComponentMsgs) Set ¶
func (d *MapComponentMsgs) Set(key, value string)
Set is to save a key-message pair
func (*MapComponentMsgs) Size ¶
func (d *MapComponentMsgs) Size() int
Size returns the number of messages
type Translation ¶
type Translation interface { // GetLocaleList Get locale list GetLocaleList(name, version string) ([]string, error) // GetComponentList Get component list GetComponentList(name, version string) ([]string, error) // GetStringMessage Get a message with optional arguments GetStringMessage(name, version, locale, component, key string, args ...string) (string, error) // GetComponentMessages Get component messages GetComponentMessages(name, version, locale, component string) (ComponentMsgs, error) // GetComponentsMessages Get messages of multiple components GetComponentsMessages(name, version string, locales, components []string) ([]ComponentMsgs, error) }
Translation interface of translation
Source Files ¶
- bundle_dao.go
- cache_default.go
- cache_info.go
- cache_interface.go
- cache_service.go
- common.go
- config.go
- consts.go
- data_default.go
- httpclient.go
- inst.go
- logger_default.go
- messages.go
- origin_chain.go
- server_dao.go
- single_loader.go
- source_as_origin.go
- source_comparison.go
- source_in_translation.go
- source_interface.go
- source_local.go
- source_locale_verification.go
- source_registration.go
- translation.go
- translation_interface.go
- translation_manager.go