gettext

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2016 License: MIT, BSD-3-Clause Imports: 8 Imported by: 0

README

gorilla/gettext

A reader & writer for gettext MO files. WIP.

Initial API docs are here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteMo

func WriteMo(w io.WriteSeeker, iter Iterator) error

WriteMo writes a MO file to w using the provided messages iterator.

Types

type Catalog

type Catalog struct {
	Header textproto.MIMEHeader
	Msgs   map[string]*Message
	Keys   []string
}

Catalog stores translations.

func NewCatalog

func NewCatalog() *Catalog

NewCatalog returns a new catalog instance.

func (*Catalog) Iter

func (c *Catalog) Iter() Iterator

Iter returns a messages iterator for this catalog.

func (*Catalog) ReadMo

func (c *Catalog) ReadMo(r io.ReadSeeker) error

ReadMo reads a MO file from r and adds its messages to the catalog.

func (*Catalog) Singular

func (c *Catalog) Singular(key string, args ...interface{}) string

Singular returns a singular string stored in the catalog, optionally formatting it using the provided arguments.

type Iterator

type Iterator interface {
	// Size returns the amount of messages provided by the iterator.
	Size() int
	// Next returns the next message. At the end of the iteration,
	// io.EOF is returned as the error.
	Next() (*Message, error)
}

Iterator iterates over gettext messages.

func ReadMo

func ReadMo(r io.ReadSeeker) Iterator

ReadMo reads a MO file from r and returns a messages iterator.

type Message

type Message struct {
	Ctxt      []byte       // msgctxt: message context, if any
	Id        []byte       // msgid: untranslated singular string
	IdPlural  []byte       // msgid_plural: untranslated plural string
	Str       []byte       // msgstr: translated singular string
	StrPlural [][]byte     // msgstr[n]: translated plural strings
	Meta      *MessageMeta // message comments from PO file
}

Message stores a gettext message.

type MessageMeta

type MessageMeta struct {
	TranslatorComments [][]byte
	ExtractedComments  [][]byte
	References         [][]byte
	Flags              [][]byte
	PrevCtxt           []byte
	PrevId             []byte
	PrevIdPlural       []byte
}

MessageMeta stores meta-data from a gettext message.

Jump to

Keyboard shortcuts

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