Deprecated: Use github.com/nicksnyder/go-i18n/v2 instead.

package translation

import "github.com/nicksnyder/go-i18n/i18n/translation"

Package translation defines the interface for a translation.

Index

Types

type SortableByID

type SortableByID []Translation

SortableByID implements sort.Interface for a slice of translations.

func (SortableByID) Len

func (a SortableByID) Len() int

func (SortableByID) Less

func (a SortableByID) Less(i, j int) bool

func (SortableByID) Swap

func (a SortableByID) Swap(i, j int)

type Translation

type Translation interface {
	// MarshalInterface returns the object that should be used
	// to serialize the translation.
	MarshalInterface() interface{}
	MarshalFlatInterface() interface{}
	ID() string
	Template(language.Plural) *template
	UntranslatedCopy() Translation
	Normalize(language *language.Language) Translation
	Backfill(src Translation) Translation
	Merge(Translation) Translation
	Incomplete(l *language.Language) bool
}

Translation is the interface that represents a translated string.

func NewTranslation

func NewTranslation(data map[string]interface{}) (Translation, error)

NewTranslation reflects on data to create a new Translation.

data["id"] must be a string and data["translation"] must be either a string for a non-plural translation or a map[string]interface{} for a plural translation.

Source Files

plural_translation.go single_translation.go template.go translation.go

Version
v1.10.3 (latest)
Published
Jan 31, 2024
Platform
js/wasm
Imports
6 packages
Last checked
32 minutes ago

Tools for package owners.