Documentation ¶
Index ¶
- Variables
- func T(category string, message string, params map[string]string, lang string) string
- type Config
- type Formatter
- type I18N
- type JSONSource
- type MessageSource
- func (ms *MessageSource) GetMsgFilePath(category string, lang string) string
- func (ms *MessageSource) LoadFallbackMsgs(category string, fallbackLang string, msgs TMsgs, originalMsgFile string) (TMsgs, error)
- func (ms *MessageSource) LoadMsgs(category string, lang string) (TMsgs, error)
- func (ms *MessageSource) Translate(category string, message string, lang string) (string, error)
- func (ms *MessageSource) TranslateMsg(category string, message string, lang string) (string, error)
- type Source
- type TMsgs
Constants ¶
This section is empty.
Variables ¶
var DefaultOriginalLang = "en-US"
DefaultOriginalLang default original language
Functions ¶
Types ¶
type Config ¶
type Config struct { SourceNewFunc func(*Config) Source OriginalLang string ForceTranslation bool BasePath string FileMap map[string]string // contains filtered or unexported fields }
Config config
type JSONSource ¶
type JSONSource struct {
MessageSource
}
JSONSource JSONSource
func (*JSONSource) GetMsgFilePath ¶
func (js *JSONSource) GetMsgFilePath(category string, lang string) string
GetMsgFilePath Get messages file path.
type MessageSource ¶
type MessageSource struct { // string the language that the original messages are in OriginalLang string ForceTranslation bool BasePath string FileMap map[string]string // contains filtered or unexported fields }
MessageSource MessageSource
func (*MessageSource) GetMsgFilePath ¶
func (ms *MessageSource) GetMsgFilePath(category string, lang string) string
GetMsgFilePath Get messages file path.
func (*MessageSource) LoadFallbackMsgs ¶
func (ms *MessageSource) LoadFallbackMsgs(category string, fallbackLang string, msgs TMsgs, originalMsgFile string) (TMsgs, error)
LoadFallbackMsgs Loads the message translation for the specified $language and $category. If translation for specific locale code such as `en-US` isn't found it tries more generic `en`. When both are present, the `en-US` messages will be merged
func (*MessageSource) LoadMsgs ¶
func (ms *MessageSource) LoadMsgs(category string, lang string) (TMsgs, error)
LoadMsgs Loads the message translation for the specified $language and $category. If translation for specific locale code such as `en-US` isn't found it tries more generic `en`. When both are present, the `en-US` messages will be merged over `en`. See [[loadFallbackTMsgs]] for details. If the lang is less specific than [[originalLang]], the method will try to load the messages for [[originalLang]]. For example: [[originalLang]] is `en-GB`, language is `en`. The method will load the messages for `en` and merge them over `en-GB`.
func (*MessageSource) TranslateMsg ¶
TranslateMsg translate message
type Source ¶
type Source interface { Translate(category string, message string, lang string) (string, error) TranslateMsg(category string, message string, lang string) (string, error) GetMsgFilePath(category string, lang string) string LoadMsgs(category string, lang string) (TMsgs, error) LoadFallbackMsgs(category string, fallbackLang string, msgs TMsgs, originalMsgFile string) (TMsgs, error) }
Source interface