pomsg

package
v0.0.0-...-c50f1b6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 12 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

func Load

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

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

Supports fallbacks for when a given locale does not exist, as long as the fallback files are in canonical form.

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

MsgidPlural 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

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
y or Y : Canonical URL