table

package
v0.0.0-...-3518944 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2017 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(ctx string, singular string, plural string) string

func Register

func Register(lang string, formula Formula, data string)

Register registers a new binary table for the given language. Keep in mind that Register is meant to be called from init and it's not thread safe. The first parameter must be either an ISO-639-1 language code, like "es" or "us", or either an ISO-639-1/ISO-3166-1-alpha2 combination, like "es_ES", "en_US" or "en_GB". Note that internally all codes are translated to uppercase and dashes are translated to underscores. This means that the languages "ES-ES", "es_es" and "es_ES" are equivalent. The second parameter is the language plural formula. The third parameter is a compressed language table. If there's already a table registered for the given language, it will be updated with the new table, adding or updating entries as required.

func Registered

func Registered() []string

Types

type Formula

type Formula func(n int) int

type Table

type Table struct {
	// contains filtered or unexported fields
}

func Decode

func Decode(data string) (*Table, error)

func Get

func Get(lang string) *Table

func New

func New(formula Formula, translations map[string]Translation) (*Table, error)

func (*Table) Encode

func (t *Table) Encode() (string, error)

func (*Table) Plural

func (t *Table) Plural(ctx string, singular string, plural string, n int) string

func (*Table) Singular

func (t *Table) Singular(ctx string, msg string) string

func (*Table) Update

func (t *Table) Update(other *Table) error

type Translation

type Translation []string

Translation is the runtime representation of a translation loaded from a table.

Jump to

Keyboard shortcuts

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