gf: github.com/gogf/gf/i18n/gi18n Index | Files

package gi18n

import "github.com/gogf/gf/i18n/gi18n"

Package gi18n implements internationalization and localization.

Index

Package Files

gi18n.go gi18n_instance.go gi18n_manager.go

Constants

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

func GetContent Uses

func GetContent(key string, language ...string) string

GetValue retrieves and returns the configured content for given key and specified language. It returns an empty string if not found.

func SetDelimiters Uses

func SetDelimiters(left, right string)

SetDelimiters sets the delimiters for translator.

func SetLanguage Uses

func SetLanguage(language string)

SetLanguage sets the language for translator.

func SetPath Uses

func SetPath(path string) error

SetPath sets the directory path storing i18n files.

func T Uses

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

T is alias of Translate for convenience.

func Tf Uses

func Tf(format string, values ...interface{}) string

Tf is alias of TranslateFormat for convenience.

func Tfl Uses

func Tfl(language string, format string, values ...interface{}) string

Tfl is alias of TranslateFormatLang for convenience.

func Translate Uses

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

Translate translates <content> with configured language and returns the translated content. The parameter <language> specifies custom translation language ignoring configured language.

func TranslateFormat Uses

func TranslateFormat(format string, values ...interface{}) string

TranslateFormat translates, formats and returns the <format> with configured language and given <values>.

func TranslateFormatLang Uses

func TranslateFormatLang(language string, format string, values ...interface{}) string

TranslateFormatLang translates, formats and returns the <format> with configured language and given <values>. The parameter <language> specifies custom translation language ignoring configured language. If <language> is given empty string, it uses the default configured language for the translation.

type Manager Uses

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

Manager, it is concurrent safe, supporting hot reload.

func Instance Uses

func Instance(name ...string) *Manager

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

func New Uses

func New(options ...Options) *Manager

New creates and returns a new i18n manager. The optional parameter <option> specifies the custom options for i18n manager. It uses a default one if it's not passed.

func (*Manager) GetContent Uses

func (m *Manager) GetContent(key string, language ...string) string

GetValue retrieves and returns the configured content for given key and specified language. It returns an empty string if not found.

func (*Manager) SetDelimiters Uses

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

SetDelimiters sets the delimiters for translator.

func (*Manager) SetLanguage Uses

func (m *Manager) SetLanguage(language string)

SetLanguage sets the language for translator.

func (*Manager) SetPath Uses

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

SetPath sets the directory path storing i18n files.

func (*Manager) T Uses

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

T is alias of Translate for convenience.

func (*Manager) Tf Uses

func (m *Manager) Tf(format string, values ...interface{}) string

Tf is alias of TranslateFormat for convenience.

func (*Manager) Tfl Uses

func (m *Manager) Tfl(language string, format string, values ...interface{}) string

Tfl is alias of TranslateFormatLang for convenience.

func (*Manager) Translate Uses

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.

func (*Manager) TranslateFormat Uses

func (m *Manager) TranslateFormat(format string, values ...interface{}) string

TranslateFormat translates, formats and returns the <format> with configured language and given <values>.

func (*Manager) TranslateFormatLang Uses

func (m *Manager) TranslateFormatLang(language string, format string, values ...interface{}) string

TranslateFormatLang translates, formats and returns the <format> with configured language and given <values>. The parameter <language> specifies custom translation language ignoring configured language. If <language> is given empty string, it uses the default configured language for the translation.

type Options Uses

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

Options is used for i18n object configuration.

func DefaultOptions Uses

func DefaultOptions() Options

DefaultOptions creates and returns a default options for i18n manager.

Package gi18n imports 13 packages (graph) and is imported by 4 packages. Updated 2020-10-27. Refresh now. Tools for package owners.