message - ActiveState ActiveGo 1.8
...

Package message

import "golang.org/x/text/message"
Overview
Index
Subdirectories

Overview ▾

Package message implements formatted I/O for localized strings with functions analogous to the fmt's print functions.

NOTE: Under construction. See https://golang.org/design/12750-localization and its corresponding proposal issue https://golang.org/issues/12750.

Variables

DefaultCatalog is used by SetString.

var DefaultCatalog *catalog.Catalog = defaultCatalog

func Set

func Set(tag language.Tag, key string, msg ...catalog.Message) error

Set calls Set on the initial default Catalog.

func SetString

func SetString(tag language.Tag, key string, msg string) error

SetString calls SetString on the initial default Catalog.

type Option

An Option defines an option of a Printer.

type Option func(o *options)

func Catalog

func Catalog(c *catalog.Catalog) Option

Catalog defines the catalog to be used.

type Printer

A Printer implements language-specific formatted I/O analogous to the fmt package. Only one goroutine may use a Printer at the same time.

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

func NewPrinter

func NewPrinter(t language.Tag, opts ...Option) *Printer

NewPrinter returns a Printer that formats messages tailored to language t.

func (*Printer) Fprint

func (p *Printer) Fprint(w io.Writer, a ...interface{}) (n int, err error)

Fprint is like fmt.Fprint, but using language-specific formatting.

func (*Printer) Fprintf

func (p *Printer) Fprintf(w io.Writer, key Reference, a ...interface{}) (n int, err error)

Fprintf is like fmt.Fprintf, but using language-specific formatting.

func (*Printer) Fprintln

func (p *Printer) Fprintln(w io.Writer, a ...interface{}) (n int, err error)

Fprintln is like fmt.Fprintln, but using language-specific formatting.

func (*Printer) Print

func (p *Printer) Print(a ...interface{}) (n int, err error)

Print is like fmt.Print, but using language-specific formatting.

func (*Printer) Printf

func (p *Printer) Printf(key Reference, a ...interface{}) (n int, err error)

Printf is like fmt.Printf, but using language-specific formatting.

func (*Printer) Println

func (p *Printer) Println(a ...interface{}) (n int, err error)

Println is like fmt.Println, but using language-specific formatting.

func (*Printer) Sprint

func (p *Printer) Sprint(a ...interface{}) string

Sprint is like fmt.Sprint, but using language-specific formatting.

func (*Printer) Sprintf

func (p *Printer) Sprintf(key Reference, a ...interface{}) string

Sprintf is like fmt.Sprintf, but using language-specific formatting.

func (*Printer) Sprintln

func (p *Printer) Sprintln(a ...interface{}) string

Sprintln is like fmt.Sprintln, but using language-specific formatting.

type Reference

A Reference is a string or a message reference.

type Reference interface {
}

func Key

func Key(id string, fallback string) Reference

Key creates a message Reference for a message where the given id is used for message lookup and the fallback is returned when no matches are found.

Subdirectories

Name Synopsis
..
catalog Package catalog defines collections of translated format strings.