i18n

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotInitialized = "..::-@#@-::.."
)

Variables

This section is empty.

Functions

func CurrentLang

func CurrentLang() string

CurrentLang return the current language

func DefaultLang

func DefaultLang() string

DefaultLang return the default language

func FillObject added in v0.2.1

func FillObject(spec interface{}) error

FillObject maps each of the object's properties with its corresponding translation key specified in the i18n tag. Example:

type Person struct {
	Name  string `i18n:"Person.Name"`
	State string `i18n:"StateLabel"`
}

func Load

func Load(c Config) error

Load apply the configuration to load language messages

func SetCurrentLang

func SetCurrentLang(lang string) error

SetCurrentLang set a language loaded in memory to use

func SetDefaultLang

func SetDefaultLang(lang string) error

SetDefaultLang set a language loaded in memory as default

func Translate

func Translate(key string) string

Translate find a entry in the language used

Types

type Config

type Config struct {
	PathLangFiles string
	DefaultLang   string
	CurrentLang   string
	// contains filtered or unexported fields
}

type CurrentLanguageTagNotExistsError

type CurrentLanguageTagNotExistsError struct{}

CurrentLanguageTagNotExistsError occurs when current language tag not exists in memory

func (*CurrentLanguageTagNotExistsError) Error

Error return error message

type InvalidSpecificationError added in v0.2.1

type InvalidSpecificationError struct{}

InvalidSpecificationError occurs when the specification is not a structure pointer or one of its properties is not of type string

func (*InvalidSpecificationError) Error added in v0.2.1

func (e *InvalidSpecificationError) Error() string

Error return error message

type LanguageFileNotFoundError

type LanguageFileNotFoundError struct{}

LanguageFileNotFoundError occurs when not language files are found in the directory

func (*LanguageFileNotFoundError) Error

func (e *LanguageFileNotFoundError) Error() string

Error return error message

type LanguageNotFoundError

type LanguageNotFoundError struct{}

LanguageNotFoundError occurs when not language is found in memory

func (*LanguageNotFoundError) Error

func (e *LanguageNotFoundError) Error() string

Error return error message

type LanguagesNotInitializedError

type LanguagesNotInitializedError struct{}

LanguagesNotInitializedError occurs when the languages are not initialized

func (*LanguagesNotInitializedError) Error

Error return error message

Jump to

Keyboard shortcuts

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