po

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	TranslatorComments []string
	ExtractedComments  []string
	References         []string
	Flags              []string
	PrevCtxt           string
	PrevId             string
	PrevIdPlural       string
}

Comment stores meta-data from a gettext message.

func (Comment) WriteTo

func (c Comment) WriteTo(w io.Writer) (n int64, err error)

Write the comment to the given writer.

type File

type File struct {
	Header    textproto.MIMEHeader
	Messages  []Message
	Pluralize PluralSelector
}

File represents a PO file.

func Parse

func Parse(r io.Reader) (File, error)

Parse reads the content of a PO file and returns the list of messages.

func (File) WriteTo

func (f File) WriteTo(w io.Writer) (n int64, err error)

Write the PO file to a destination writer.

type Message

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

Message stores a gettext message.

func (Message) WriteTo

func (m Message) WriteTo(w io.Writer) (n int64, err error)

Write the PO Message to a destination writer.

type PluralSelector

type PluralSelector func(n int) int

PluralSelector returns the appropriate plural case to use, given a quantity.

func PluralSelectorForLanguage

func PluralSelectorForLanguage(lang string) PluralSelector

PluralSelectorForLanguage returns the appropriate plural selector for the provided languge code. The code can be either the too letter code ("en") or the 5 character variant ("en_GB")

Jump to

Keyboard shortcuts

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