internal

package
v2.0.0-...-92b0550 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	// ID uniquely identifies the message.
	ID string

	// Hash uniquely identifies the content of the message
	// that this message was translated from.
	Hash string

	// Description describes the message to give additional
	// context to translators that may be relevant for translation.
	Description string

	// LeftDelim is the left Go template delimiter.
	LeftDelim string

	// RightDelim is the right Go template delimiter.“
	RightDelim string

	// Zero is the content of the message for the CLDR plural form "zero".
	Zero string

	// One is the content of the message for the CLDR plural form "one".
	One string

	// Two is the content of the message for the CLDR plural form "two".
	Two string

	// Few is the content of the message for the CLDR plural form "few".
	Few string

	// Many is the content of the message for the CLDR plural form "many".
	Many string

	// Other is the content of the message for the CLDR plural form "other".
	Other string
}

Message is a string that can be localized.

func MustNewMessage

func MustNewMessage(data interface{}) *Message

MustNewMessage is similar to NewMessage except it panics if an error happens.

func NewMessage

func NewMessage(data interface{}) (*Message, error)

NewMessage parses data and returns a new message.

type MessageFile

type MessageFile struct {
	Path     string
	Tag      language.Tag
	Format   string
	Messages []*Message
}

MessageFile represents a parsed message file.

func ParseMessageFileBytes

func ParseMessageFileBytes(buf []byte, path string, unmarshalFuncs map[string]UnmarshalFunc) (*MessageFile, error)

ParseMessageFileBytes returns the messages parsed from file.

type MessageTemplate

type MessageTemplate struct {
	*Message
	PluralTemplates map[plural.Form]*Template
}

MessageTemplate is an executable template for a message.

func NewMessageTemplate

func NewMessageTemplate(m *Message) *MessageTemplate

NewMessageTemplate returns a new message template.

func (*MessageTemplate) Execute

func (mt *MessageTemplate) Execute(pluralForm plural.Form, data interface{}, funcs template.FuncMap) (string, error)

Execute executes the template for the plural form and template data.

type Template

type Template struct {
	Src      string
	Template *gotemplate.Template
	ParseErr *error
}

Template stores the template for a string.

type UnmarshalFunc

type UnmarshalFunc func(data []byte, v interface{}) error

UnmarshalFunc unmarshals data into v.

Directories

Path Synopsis
Package plural provides support for pluralizing messages according to CLDR rules http://cldr.unicode.org/index/cldr-spec/plural-rules
Package plural provides support for pluralizing messages according to CLDR rules http://cldr.unicode.org/index/cldr-spec/plural-rules

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL