i18n

package module
v0.0.0-...-8a6679f Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: MIT Imports: 9 Imported by: 0

README

go-i18n

日本語

  • A template repository for Go language libraries.

After creating the repository

  • Replace mythrnr/go-i18n with the name of the repository you created.
  • Change LICENSE to match your own library.

Status

Check codes

Create Release

Description

This package is awesome.

Requirements

Go 1.13 or above.

Install

Get it with go get.

go get github.com/mythrnr/go-i18n

Usage

Write usage.

Documentation

Overview

Package i18n provides internationalize.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMessageValueTypeInvalid = errors.New("invalid message value")
	ErrYAMLCannotBind          = errors.New("invalid target type")
	ErrYAMLKeyNotString        = errors.New("invalid YAML key")
	ErrYAMLValueTypeInvalid    = errors.New("invalid YAML value")
)

Functions

This section is empty.

Types

type Fallback

type Fallback func(key string) string

type Formatter

type Formatter func(v interface{}) string

type Loader

type Loader interface {
	Load(data []byte) (*M, error)
	LoadFile(path string) (*M, error)
}

func NewJSONLoader

func NewJSONLoader() Loader

func NewYAMLLoader

func NewYAMLLoader() Loader

type Localizer

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

func NewLocalizer

func NewLocalizer(msg *M) *Localizer

func (*Localizer) Fallback

func (l *Localizer) Fallback(fn Fallback) *Localizer

func (*Localizer) Formatter

func (l *Localizer) Formatter(fn Formatter) *Localizer

func (*Localizer) Get

func (l *Localizer) Get(key string) string

func (*Localizer) GetNum

func (l *Localizer) GetNum(key string, n uint) string

func (*Localizer) GetNumf

func (l *Localizer) GetNumf(key string, n uint, args ...interface{}) string

func (*Localizer) Getf

func (l *Localizer) Getf(key string, args ...interface{}) string

func (*Localizer) NTCf

func (l *Localizer) NTCf(key string, n uint, rep R) string

func (*Localizer) NTf

func (l *Localizer) NTf(key string, rep R) string

func (*Localizer) NamedGetNumf

func (l *Localizer) NamedGetNumf(key string, n uint, rep R) string

func (*Localizer) NamedGetf

func (l *Localizer) NamedGetf(key string, rep R) string

func (*Localizer) Selector

func (l *Localizer) Selector(fn Selector) *Localizer

func (*Localizer) T

func (l *Localizer) T(key string) string

func (*Localizer) TC

func (l *Localizer) TC(key string, n uint) string

func (*Localizer) TCf

func (l *Localizer) TCf(key string, n uint, args ...interface{}) string

func (*Localizer) Tf

func (l *Localizer) Tf(key string, args ...interface{}) string

type M

type M = Message

type Message

type Message map[string]interface{}

type R

type R = Replace

type Replace

type Replace map[string]interface{}

type Selector

type Selector func(n uint) uint

type Translator

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

func NewTranslator

func NewTranslator() *Translator

func (*Translator) Add

func (t *Translator) Add(tag language.Tag, l *Localizer)

func (*Translator) Fallback

func (t *Translator) Fallback(l *Localizer)

func (*Translator) IsSupported

func (t *Translator) IsSupported(tag language.Tag) bool

func (*Translator) L

func (t *Translator) L(tag language.Tag) *Localizer

func (*Translator) Localizer

func (t *Translator) Localizer(tag language.Tag) *Localizer

Jump to

Keyboard shortcuts

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