gi18n

package
v1.8.4-0...-cbac34e Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package gi18n implements internationalization and localization.

Index

Constants

View Source
const (
	// Default group name for instance usage.
	DEFAULT_NAME = "default"
)

Variables

This section is empty.

Functions

func SetDelimiters

func SetDelimiters(left, right string)

SetDelimiters sets the delimiters for translator.

func SetLanguage

func SetLanguage(language string)

SetLanguage sets the language for translator.

func SetPath

func SetPath(path string) error

SetPath sets the directory path storing i18n files.

func T

func T(content string, language ...string) string

T is alias of Translate.

func Translate

func Translate(content string, language ...string) string

Translate translates <content> with configured language. The parameter <language> specifies custom translation language ignoring configured language.

Types

type Manager

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

Manager, it is concurrent safe, supporting hot reload.

func Instance

func Instance(name ...string) *Manager

Instance returns an instance of Resource. The parameter <name> is the name for the instance.

func New

func New(options ...Options) *Manager

New creates and returns a new i18n manager.

func (*Manager) SetDelimiters

func (m *Manager) SetDelimiters(left, right string)

SetDelimiters sets the delimiters for translator.

func (*Manager) SetLanguage

func (m *Manager) SetLanguage(language string)

SetLanguage sets the language for translator.

func (*Manager) SetPath

func (m *Manager) SetPath(path string) error

SetPath sets the directory path storing i18n files.

func (*Manager) T

func (m *Manager) T(content string, language ...string) string

T is alias of Translate.

func (*Manager) Translate

func (m *Manager) Translate(content string, language ...string) string

Translate translates <content> with configured language. The parameter <language> specifies custom translation language ignoring configured language.

type Options

type Options struct {
	Path       string   // I18n files storage path.
	Language   string   // Local language.
	Delimiters []string // Delimiters for variable parsing.
}

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the default options for i18n manager.

Jump to

Keyboard shortcuts

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