Documentation ¶
Overview ¶
Package pipeline provides tools for creating translation pipelines.
NOTE: UNDER DEVELOPMENT. API MAY CHANGE.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate writes a Go file with the given package name to w, which defines a Catalog with translated messages.
Types ¶
type Config ¶
type Config struct { SourceLanguage language.Tag // Supported indicates the languages for which data should be generated. // If unspecified, it will attempt to derive the set of supported languages // from the context. Supported []language.Tag Packages []string }
Config contains configuration for the translation pipeline.
type Feature ¶
type Feature struct {
Type string `json:"type"` // Right now this is only gender and plural.
}
Feature holds information about a feature that can be implemented by an Argument.
type IDList ¶
type IDList []string
IDList is a set identifiers that each may refer to possibly different versions of the same message. When looking up a messages, the first identifier in the list takes precedence.
func (*IDList) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*IDList) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Locale ¶
type Locale struct { Language language.Tag `json:"language"` Messages []Message `json:"messages"` Macros map[string]Text `json:"macros,omitempty"` }
A Locale is used to store all information for a single locale. This type is used both for extraction and injection.
type Message ¶
type Message struct { // ID contains a list of identifiers for the message. ID IDList `json:"id"` // Key is the string that is used to look up the message at runtime. Key string `json:"key"` Meaning string `json:"meaning,omitempty"` Message Text `json:"message"` Translation Text `json:"translation"` Comment string `json:"comment,omitempty"` TranslatorComment string `json:"translatorComment,omitempty"` Placeholders []Placeholder `json:"placeholders,omitempty"` // Extraction information. Position string `json:"position,omitempty"` // filePosition:line }
A Message describes a message to be translated.
func (*Message) Placeholder ¶
func (m *Message) Placeholder(id string) *Placeholder
Placeholder reports the placeholder for the given ID if it is defined or nil otherwise.
type Placeholder ¶
type Placeholder struct { // ID is the placeholder identifier without the curly braces. ID string `json:"id"` // String is the string with which to replace the placeholder. This may be a // formatting string (for instance "%d" or "{{.Count}}") or a literal string // (<div>). String string `json:"string"` Type string `json:"type"` UnderlyingType string `json:"underlyingType"` // ArgNum and Expr are set if the placeholder is a substitution of an // argument. ArgNum int `json:"argNum,omitempty"` Expr string `json:"expr,omitempty"` Comment string `json:"comment,omitempty"` Example string `json:"example,omitempty"` // Features contains the features that are available for the implementation // of this argument. Features []Feature `json:"features,omitempty"` }
A Placeholder is a part of the message that should not be changed by a translator. It can be used to hide or prettify format strings (e.g. %d or {{.Count}}), hide HTML, or mark common names that should not be translated.
type Select ¶
type Select struct { Feature string `json:"feature"` // Name of Feature type (e.g plural) Arg string `json:"arg"` // The placeholder ID Cases map[string]Text `json:"cases"` }
Select selects a Text based on the feature value associated with a feature of a certain argument.
type Text ¶
type Text struct { // Msg and Select contains the message to be displayed. Msg may be used as // a fallback value if none of the select cases match. Msg string `json:"msg,omitempty"` Select *Select `json:"select,omitempty"` // Var defines a map of variables that may be substituted in the selected // message. Var map[string]Text `json:"var,omitempty"` // Example contains an example message formatted with default values. Example string `json:"example,omitempty"` }
Text defines a message to be displayed.
func (*Text) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Text) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.