Help us shape the future of Go! Take the 2026 Go Developer Survey

locale

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2018 License: MIT Imports: 2 Imported by: 0

README

locale

Simple wrapper for go-i18n

Installation

Before use this validator, you need to install go-i18n first, and then install this package.

go get github.com/ramadani/locale

Usage

Register the package

locale.Register(func() *i18n.Localizer {
	bundle := &i18n.Bundle{DefaultLanguage: language.Indonesian}
	bundle.RegisterUnmarshalFunc("yml", yaml.Unmarshal)
	bundle.MustLoadMessageFile("resources/lang/id-ID.yml")

	return i18n.NewLocalizer(bundle, "id-ID")
})

And then, you can use it on your go project

trans := locale.Locale()
subject := trans.Trans("password_reset_mail_subject")
// Password Reset Confirmation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(regFunc RegisterFunc)

Types

type Localable

type Localable interface {
	Trans(key string, datas ...TemplateData) string
}

func Locale

func Locale() Localable

type RegisterFunc

type RegisterFunc func() *i18n.Localizer

type TemplateData

type TemplateData map[string]interface{}

Jump to

Keyboard shortcuts

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