Documentation ¶
Index ¶
- Constants
- Variables
- func IndexToCode(index Index) string
- func IsLanguageName(b []byte) bool
- func Supported() []string
- func TranslationResource(dir string, langfilename string, customSuffixes ...string) ([]string, error)
- func WithBrackets(bracketSymbol string) func(o *Option)
- func WithPrimaryLanguage(li Index) func(o *Option)
- func WithSuffixes(suffix ...string) func(o *Option)
- type Container
- func (c *Container) AddCustomDir(dirs ...string) error
- func (c *Container) AddFileByMask(dir string, mask string) error
- func (c *Container) AddFiles(filenames ...string) error
- func (c *Container) Lang(li Index) ContainerRequest
- func (c *Container) ListenFileChange() error
- func (c *Container) ReadRegisteredFiles() error
- type ContainerRequest
- type Index
- type Item
- type Name
- type NameColumn
- type Option
- type RequestStrategy
- type ResponseItem
- type Set
Constants ¶
const UnknownLanguageCode = "?"
Variables ¶
var ( FileExtension = ".i18n" HintSeparator = "//" NotFoundMarker = "\u2638" )
Functions ¶
func IsLanguageName ¶
func TranslationResource ¶
func WithBrackets ¶ added in v0.2.0
WithBrackets assignss wrapping symbol used by .
func WithPrimaryLanguage ¶ added in v0.2.0
WithPrimaryLanguage assigns a primary language.
func WithSuffixes ¶ added in v0.2.0
WithSuffixes assigns suffixes of translation files in the order of applying priority. The first suffix has the highest priority.
Types ¶
type Container ¶ added in v0.2.0
type Container struct {
// contains filtered or unexported fields
}
Container stores for all translation resources.
func (*Container) AddCustomDir ¶ added in v0.2.0
AddCustomDir registers a directory with custom translation files.
func (*Container) AddFileByMask ¶ added in v0.2.0
AddFileByMask registers .i18n files matching mask from the path specified by path.
func (*Container) AddFiles ¶ added in v0.2.0
AddFiles registers .i18n files in the container. Returns error if even one could not be found or it's a directory.
func (*Container) Lang ¶ added in v0.2.0
func (c *Container) Lang(li Index) ContainerRequest
func (*Container) ListenFileChange ¶ added in v0.2.0
func (*Container) ReadRegisteredFiles ¶ added in v0.2.0
ReadRegisteredFiles reads content of all registered files and stores items in the container.
type ContainerRequest ¶ added in v0.2.0
type ContainerRequest struct {
// contains filtered or unexported fields
}
func (*ContainerRequest) Hint ¶ added in v0.2.0
func (c *ContainerRequest) Hint(id string) string
func (*ContainerRequest) JSON ¶ added in v0.2.0
func (cr *ContainerRequest) JSON() ([]byte, error)
JSON returns translation in JSON format.
func (*ContainerRequest) Value ¶ added in v0.2.0
func (c *ContainerRequest) Value(id string) string
func (*ContainerRequest) ValueWithDefault ¶ added in v0.2.0
func (c *ContainerRequest) ValueWithDefault(id string, notFoundValue string) string
type Index ¶
type Index int
Index is integer representative of language short code.
const Unknown Index = -1
Unknown value is used if language code is not found.
func SetNoLanguage ¶ added in v0.1.1
type Name ¶
type Name []string
Name holds decoded names. Index of the slice calculates by ToIndex().
func (Name) MarshalJSON ¶
func (*Name) UnmarshalJSON ¶
type NameColumn ¶
type NameColumn []byte
NameColumn is a type of column Name in regular reference table
func (NameColumn) Name ¶
func (rn NameColumn) Name() (Name, error)
Name decodes jsonb into array of strings
type Option ¶ added in v0.2.0
type Option struct {
// contains filtered or unexported fields
}
Option defines options for Container.
type RequestStrategy ¶ added in v0.2.0
type RequestStrategy int8
const ( ReturnNotFoundVariable RequestStrategy = iota ReturnEmptyString ReturnInPrimaryLanguage )
type ResponseItem ¶ added in v0.2.0
ResponseItem represents a row to be returned to the client.