Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Catalog ¶
type Catalog interface { // GetTranslation Returns a translation for an ID within a given context. GetTranslation(ctx, msgID string) (string, error) // GetPluralTranslation Returns a translation within a given context. // Here n is a number that should be used to determine the plural form. GetPluralTranslation(ctx, msgID string, n interface{}) (string, error) Language() language.Tag }
Catalog represents a collection of messages (translations) for a language and a domain. Normally it is a PO or MO file.
type Decoder ¶
A Decoder reads and decodes catalogs for a language and a domain from a byte array.
func NewJSONDecoder ¶
func NewJSONDecoder() Decoder
NewJSONDecoder returns a new Decoder for reading JSON files. The structure follows a key-value structure, where the key is either an ID or the singular text of the source language. For singular-only texts, the value is a string with a translation. For plural texts it is an object with the CLDR plural forms and the matching translations.
func NewMoCLDRDecoder ¶
func NewMoCLDRDecoder() Decoder
NewMoCLDRDecoder creates a decoder for reading mo files, which always uses the CLDR plural rules for determining the plural form. If no matching CLDR rule exists, the Mo header rule is used. If no header exists, the english plural rules (1 is singular, otherwise plural) are used. Attention: The "Plural-Forms" header inside the Mo file is ignored when using the CLDR rules. To ensure optimal compatibility with other applications, care should be taken to ensure that the Mo header is compatible with the CLDR rules.
func NewMoDecoder ¶
func NewMoDecoder() Decoder
NewMoDecoder returns a new Decoder for reading mo files. If a plural forms header is set, it will be used. Otherwise, the CLDR plural rules are used to set the plural form. If there is no CLDR plural rule, the English plural rules will be used.
func NewPoCLDRDecoder ¶
func NewPoCLDRDecoder() Decoder
NewPoCLDRDecoder creates a decoder for reading po files, which always uses the CLDR plural rules for determining the plural form. If no matching CLDR rule exists, the Po header rule is used. If no header exists, the english plural rules (1 is singular, otherwise plural) are used. Attention: The "Plural-Forms" header inside the Po file is ignored when using the CLDR rules. To ensure optimal compatibility with other applications, care should be taken to ensure that the Po header is compatible with the CLDR rules.
func NewPoDecoder ¶
func NewPoDecoder() Decoder
NewPoDecoder returns a new Decoder for reading po files. If a plural forms header is set, it will be used. Otherwise, the CLDR plural rules are used to set the plural form. If there is no CLDR plural rule, the English plural rules will be used.
type ErrMissingContext ¶
ErrMissingContext is the error returned when a matching context was not found for a language and domain.
func NewErrMissingContext ¶
func NewErrMissingContext(lang language.Tag, domain, context string) *ErrMissingContext
func (*ErrMissingContext) Error ¶
func (e *ErrMissingContext) Error() string
func (*ErrMissingContext) String ¶
func (e *ErrMissingContext) String() string
type ErrMissingMessageID ¶
ErrMissingMessageID is the error returned when a matching message was not found for a language and domain.
func NewErrMissingMessageID ¶
func NewErrMissingMessageID(lang language.Tag, domain, context, msgID string) *ErrMissingMessageID
func (*ErrMissingMessageID) Error ¶
func (e *ErrMissingMessageID) Error() string
func (*ErrMissingMessageID) String ¶
func (e *ErrMissingMessageID) String() string
type ErrMissingTranslation ¶
type ErrMissingTranslation struct { Language language.Tag Domain string Context string MsgID string Idx int }
ErrMissingTranslation is the error returned when there is no translation for a domain of a language for a message.
func NewErrMissingTranslation ¶
func NewErrMissingTranslation(lang language.Tag, domain, context, msgID string, idx int) *ErrMissingTranslation
func (*ErrMissingTranslation) Error ¶
func (e *ErrMissingTranslation) Error() string
func (*ErrMissingTranslation) String ¶
func (e *ErrMissingTranslation) String() string
Directories ¶
Path | Synopsis |
---|---|
This file is generated by cldrplural/generator/generate.sh; DO NOT EDIT
|
This file is generated by cldrplural/generator/generate.sh; DO NOT EDIT |
Package po allows to read and write gettext po files.
|
Package po allows to read and write gettext po files. |
This file is generated by poplural/generator/main.go; DO NOT EDIT
|
This file is generated by poplural/generator/main.go; DO NOT EDIT |