message

package
v0.0.0-...-9e2f80a Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2017 License: BSD-3-Clause Imports: 9 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

View Source
var DefaultCatalog *catalog.Catalog = defaultCatalog

DefaultCatalog is used by SetString.

Functions

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.

Types

type Option

type Option func(o *options)

An Option defines an option of a Printer.

func Catalog

func Catalog(c *catalog.Catalog) Option

Catalog defines the catalog to be used.

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, 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

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.

Directories

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

Jump to

Keyboard shortcuts

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