text: golang.org/x/text/message Index | Files | Directories

package message

import "golang.org/x/text/message"

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

These are the important differences with fmt:

- Output varies per locale.
- The '#' flag is used to bypass localization.

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

Index

Package Files

catalog.go format.go message.go print.go

Variables

var DefaultCatalog *catalog.Catalog = defaultCatalog

DefaultCatalog is used by SetString.

func Set Uses

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

Set calls Set on the initial default Catalog.

func SetString Uses

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

SetString calls SetString on the initial default Catalog.

type Option Uses

type Option func(o *options)

An Option defines an option of a Printer.

func Catalog Uses

func Catalog(c *catalog.Catalog) Option

Catalog defines the catalog to be used.

type Printer Uses

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

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

func NewPrinter Uses

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

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

func (*Printer) Fprint Uses

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 Uses

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 Uses

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 Uses

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

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

func (*Printer) Printf Uses

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 Uses

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

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

func (*Printer) Sprint Uses

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

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

func (*Printer) Sprintf Uses

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

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

func (*Printer) Sprintln Uses

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

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

type Reference Uses

type Reference interface {
}

A Reference is a string or a message reference.

func Key Uses

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.

Directories

PathSynopsis
catalogPackage catalog defines collections of translated format strings.

Package message imports 11 packages (graph) and is imported by 2 packages. Updated 2017-08-15. Refresh now. Tools for package owners.