soymsg

package
v0.0.0-...-4dafff4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2017 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlaceholderString

func PlaceholderString(n *ast.MsgNode) string

PlaceholderString returns a string representation of the message containing braced placeholders for variables.

func SetPlaceholdersAndID

func SetPlaceholdersAndID(n *ast.MsgNode)

SetPlaceholdersAndID generates and sets placeholder names for all children nodes, and generates and sets the message ID.

Types

type Bundle

type Bundle interface {
	// Locale returns the locale of the bundle.
	Locale() string

	// Message returns the message with the given id, or nil if none was found.
	Message(id uint64) *Message

	// PluralCase returns the index of the case to use for the given plural value.
	PluralCase(n int) int
}

Bundle is the set of messages available in a particular locale.

type Message

type Message struct {
	ID    uint64 // ID is a content-based identifier for this message
	Parts []Part // Parts are the sequence of message parts that form the content.
}

Message is a (possibly) translated message

func NewMessage

func NewMessage(id uint64, phstr string) *Message

NewMessage returns a new message, given its ID and placeholder string. TODO: plural parts are not parsed from the placeholder string.

type Part

type Part interface{}

Part is an element of a Message. It may be one of the following concrete types: RawTextPart, PlaceholderPart, PluralPart

func Parts

func Parts(str string) []Part

Parts returns the sequence of raw text and placeholders for the given message placeholder string.

type PlaceholderPart

type PlaceholderPart struct {
	Name string
}

PlaceholderPart is a segment of a message that stands in for another node.

type PluralCase

type PluralCase struct {
	Spec  PluralSpec
	Parts []Part
}

PluralCase is one version of the message, for a particular plural case.

type PluralPart

type PluralPart struct {
	VarName string
	Cases   []PluralCase
}

PluralPart is a segment of a message that has multiple forms depending on a value.

type PluralSpec

type PluralSpec struct {
	Type          PluralSpecType
	ExplicitValue int // only set if Type == PluralSpecExplicit
}

PluralSpec is a description of a particular plural case.

type PluralSpecType

type PluralSpecType int

PluralSpecType is the CLDR plural class.

const (
	PluralSpecExplicit PluralSpecType = iota
	PluralSpecZero
	PluralSpecOne
	PluralSpecTwo
	PluralSpecFew
	PluralSpecMany
	PluralSpecOther
)

type Provider

type Provider interface {
	// Bundle returns messages for the given locale, which is in the form
	// [language_territory]. If no locale-specific messages could be found, an
	// empty bundle is returned, which will cause all messages to use the source
	// text.
	Bundle(locale string) Bundle
}

Provider provides access to message bundles by locale.

type RawTextPart

type RawTextPart struct {
	Text string
}

RawTextPart is a segment of a message that displays the contained text.

Directories

Path Synopsis
Package pomsg provides a PO file implementation for Soy message bundles
Package pomsg provides a PO file implementation for Soy message bundles
xgettext-soy
xgettext-soy is a tool to extract messages from Soy templates in the PO (gettext) file format.
xgettext-soy is a tool to extract messages from Soy templates in the PO (gettext) file format.

Jump to

Keyboard shortcuts

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