Skip to content

kohkimakimoto/go-i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-i18n

Build Status

Minimum i18n package for Go.

Usage

import (
	"fmt"

	"github.com/kohkimakimoto/go-i18n"
)

func main() {
	I18n := &i18n.I18n{
		Translations: i18n.Translations{
			// 'en' is a default fallback locale.
			"en": {
				"hello world!": "hello world!",
				"hoge":         "Hoge",
			},
			"ja": {
				"hello world!": "こんにちは世界!",
			},
		},
	}

	// You can override default fallback locale
	// I18n.FallbackLocale = "ja"

	// Create translate function for 'ja' locale
	t := I18n.TFunc("ja")

	fmt.Println(t("hello world!"))
	// こんにちは世界!
	fmt.Println(t("hoge"))
	// Hoge
	fmt.Println(t("foo"))
	// foo
}

Author

Kohki Makimoto kohki.makimoto@gmail.com

License

The MIT License (MIT)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages