Documentation
¶
Overview ¶
Package catalog reads gotext message catalogs: one directory per locale under a locales directory, each holding messages.gotext.json and out.gotext.json.
Index ¶
Constants ¶
const ( // BaseLocale is the source locale every other locale translates from. BaseLocale = "en-US" // MessagesFile is a locale's curated catalog, where translators write translations. MessagesFile = "messages.gotext.json" // OutFile is the catalog gotext extracts from source on each run. OutFile = "out.gotext.json" )
Variables ¶
This section is empty.
Functions ¶
func LocaleDirs ¶
LocaleDirs returns the sorted locale directories under localesDir, following symlinks. It skips files, such as a stray .DS_Store, and hidden directories.
func Placeholders ¶
Placeholders returns the placeholders in text, such as {Name}, in order of appearance.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document edits a catalog file without disturbing what it doesn't change: every entry keeps its fields, field order, and id form, and unknown fields survive. Save reindents the file with the indent it was read with.
func LoadDocument ¶
LoadDocument reads the catalog at path for editing.
func (*Document) AppendFrom ¶
AppendFrom adds a copy of source's entry for id, translated as text. source is usually the base locale, so the new entry carries its message, placeholders, and comments.
type ID ¶
type ID string
ID is a message id. gotext writes it as a string or as a [key, fallback] array; ID keeps the first element.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON accepts both id forms.
type Message ¶
type Message struct {
ID ID `json:"id"`
Message string `json:"message"`
Translation any `json:"translation"`
}
Message is one catalog entry. Translation is a string, or an object for plural and select messages.
func (Message) Untranslated ¶
Untranslated reports whether the message has no translation, or an empty one.