bundle

package
v6.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2014 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package bundle manages translations for multiple languages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bundle

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

Bundle stores the translations for multiple languages.

func New

func New() *Bundle

New returns an empty bundle.

func (*Bundle) AddTranslation

func (b *Bundle) AddTranslation(lang *language.Language, translations ...translation.Translation)

AddTranslation adds translations for a language.

It is useful if your translations are in a format not supported by LoadTranslationFile.

func (*Bundle) LoadTranslationFile

func (b *Bundle) LoadTranslationFile(filename string) error

LoadTranslationFile loads the translations from filename into memory.

The language that the translations are associated with is parsed from the filename (e.g. en-US.json).

Generally you should load translation files once during your program's initialization.

func (*Bundle) MustLoadTranslationFile

func (b *Bundle) MustLoadTranslationFile(filename string)

MustLoadTranslationFile is similar to LoadTranslationFile except it panics if an error happens.

func (*Bundle) MustTfunc

func (b *Bundle) MustTfunc(languageSource string, languageSources ...string) TranslateFunc

MustTfunc is similar to Tfunc except it panics if an error happens.

func (*Bundle) Tfunc

func (b *Bundle) Tfunc(src string, srcs ...string) (TranslateFunc, error)

Tfunc returns a TranslateFunc that will be bound to the first language which has a non-zero number of translations in the bundle.

It can parse languages from Accept-Language headers (RFC 2616).

func (*Bundle) Translations

func (b *Bundle) Translations() map[string]map[string]translation.Translation

Translations returns all translations in the bundle.

type TranslateFunc

type TranslateFunc func(translationID string, args ...interface{}) string

TranslateFunc is a copy of i18n.TranslateFunc to avoid a circular dependency.

Jump to

Keyboard shortcuts

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