pomsg

package
Version: v0.0.0-...-4dafff4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2017 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package pomsg provides a PO file implementation for Soy message bundles

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(dirname string) (soymsg.Provider, error)

Dir returns a soymsg.Provider that takes translations from the given path. For example, if dir is "/usr/local/msgs", po files should be of the form:

/usr/local/msgs/<lang>.po
/usr/local/msgs/<lang>_<territory>.po

TODO: Fallbacks between <lang> and <lang>_<territory>

func Load

func Load(opener FileOpener, locales []string) (soymsg.Provider, error)

Load returns a soymsg.Provider that takes its translations by passing in the specifified locales to the given PoFileProvider.

TODO: Fallbacks between <lang> and <lang>_<territory>

func Msgid

func Msgid(n *ast.MsgNode) string

MsgId returns the msgid for the given msg node.

func MsgidPlural

func MsgidPlural(n *ast.MsgNode) string

MsgPlural returns the msgid_plural for the given message.

func Validate

func Validate(n *ast.MsgNode) error

Validate checks if the given message is representable in a PO file. A MsgNode must be validated before trying to caculate its msgid or msgid_plural

Rules:

- If a message contains a plural, it must be the sole child.
- A plural contains exactly {case 1} and {default} cases.

Types

type FileOpener

type FileOpener interface {
	// Open returns ReadCloser for the po file indicated by locale. It returns
	// nil if the file does not exist
	Open(locale string) (io.ReadCloser, error)
}

FileOpener defines an abstraction for opening a po file given a locale

Source Files

Directories

Path Synopsis
xgettext-soy is a tool to extract messages from Soy templates in the PO (gettext) file format.
xgettext-soy is a tool to extract messages from Soy templates in the PO (gettext) file format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL