/i18n

Internationalization implemetation for golang

Primary LanguageGoBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Internationalization Build Status Coverage Status Go Report Card GoDoc Release

This package is built on top of text/language and text/message.

Usage

Please take a look of the following example:

$ cd i18n/example
$ go run main.go
## fallback language(default to English)
$ curl "http://localhost:1234"
Home

## retrieve prefered language from URL query
$ curl "http://localhost:1234?lang=zh"
主页

## retrieve prefered language Cookie
$ curl -b "lang=zh-Hant" "http://localhost:1234"
主頁

## retrieve prefered language from header
$ curl -H "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-US;q=0.7,zh-TW;q=0.6,pt;q=0.5" "http://localhost:1234/hello?name=foo"
你好,foo

Integrate with other frameworks

It is easy to integrate with other frameworks by Handler or Middleware, and then retrieves translator in handler by GetTranslator.