message

package
v0.1.3-beta Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2016 License: GPL-3.0, BSD-3-Clause Imports: 7 Imported by: 0

Documentation

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetString

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

SetString calls SetString on the default Catalog.

Types

type Catalog

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

A Catalog holds translations for messages for supported languages.

var DefaultCatalog *Catalog = newCatalog()

DefaultCatalog is used by SetString.

func (*Catalog) Languages

func (c *Catalog) Languages() []language.Tag

Languages returns a slice of all languages for which the Catalog contains variants.

func (*Catalog) Printer

func (c *Catalog) Printer(tag language.Tag) *Printer

Printer creates a Printer that uses c.

func (*Catalog) SetString

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

SetString sets the translation for the given language and key.

type Printer

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

func NewPrinter(t language.Tag) *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

type Reference interface {
}

A Reference is a string or a message reference.

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.

Jump to

Keyboard shortcuts

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