loader

package
v0.0.0-...-d2e4435 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoTextJSONLoader

type GoTextJSONLoader struct {
	// contains filtered or unexported fields
}

GoTextJSONLoader loads strings from files in the JSON format supported by gotext.

func NewGoTextJSONLoader

func NewGoTextJSONLoader() *GoTextJSONLoader

NewGoTextJSONLoader factory method.

func (*GoTextJSONLoader) NeedsTag

func (ldr *GoTextJSONLoader) NeedsTag() bool

NeedsTag implements the Loader interface.

func (*GoTextJSONLoader) ReadMessages

func (ldr *GoTextJSONLoader) ReadMessages(reader io.Reader, tag *language.Tag, modTime time.Time) error

ReadMessages implements the Loader interface.

func (*GoTextJSONLoader) StringsByTag

func (ldr *GoTextJSONLoader) StringsByTag(tag language.Tag) (*StringCatalog, error)

StringsByTag gets the string table for the given language tag.

type Loader

type Loader interface {
	StringsByTag(tag language.Tag) (*StringCatalog, error)

	// NeedsTag indicates whether or not this loader requires that the language tag
	// be passed or if it can be inferred from the file format.
	NeedsTag() bool

	// ReadMessages loads messages from the given reader.
	// tag may be ignored by the implementation if NeedsTag is false.
	ReadMessages(reader io.Reader, tag *language.Tag, modTime time.Time) error
}

Loader loads messages.

type POLoader

type POLoader struct {
	// contains filtered or unexported fields
}

POLoader loads strings from files in the gettext PO format.

func NewPOLoader

func NewPOLoader() *POLoader

NewPOLoader factory method.

func (*POLoader) NeedsTag

func (ldr *POLoader) NeedsTag() bool

NeedsTag implements the Loader interface.

func (*POLoader) ReadMessages

func (ldr *POLoader) ReadMessages(reader io.Reader, tag *language.Tag, modTime time.Time) error

ReadMessages implements the Loader interface.

func (*POLoader) StringsByTag

func (ldr *POLoader) StringsByTag(tag language.Tag) (*StringCatalog, error)

StringsByTag gets the string table for the given language tag.

type StringCatalog

type StringCatalog struct {
	Strings     map[string]string
	LastModTime time.Time
}

StringCatalog lets us store an entire catalog by tag.

func NewStringCatalog

func NewStringCatalog(modTime time.Time) *StringCatalog

NewStringCatalog factory method.

type StringTable

type StringTable struct {
	LocalesDir string
	Matcher    *language.Matcher
	Loader     Loader
	// contains filtered or unexported fields
}

StringTable loads all the languages from a base directory of locales.

func NewStringTable

func NewStringTable(localesDir string, watch bool, ldr Loader) (*StringTable, error)

NewStringTable is a factory method for StringTable

func (*StringTable) Close

func (st *StringTable) Close()

Close deinitializes the StringTable.

func (*StringTable) Load

func (st *StringTable) Load() error

Load loads the languages from the configured local directory.

type XLIFF2Loader

type XLIFF2Loader struct {
	// contains filtered or unexported fields
}

XLIFF2Loader loads strings from files in the XLIFF 2 format.

func NewXLIFF2Loader

func NewXLIFF2Loader() *XLIFF2Loader

NewXLIFF2Loader factory method.

func (*XLIFF2Loader) NeedsTag

func (ldr *XLIFF2Loader) NeedsTag() bool

NeedsTag implements the Loader interface.

func (*XLIFF2Loader) ReadMessages

func (ldr *XLIFF2Loader) ReadMessages(reader io.Reader, tag *language.Tag, modTime time.Time) error

ReadMessages implements the Loader interface.

func (*XLIFF2Loader) StringsByTag

func (ldr *XLIFF2Loader) StringsByTag(tag language.Tag) (*StringCatalog, error)

StringsByTag gets the string table for the given language tag.

Jump to

Keyboard shortcuts

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