Skip to content
Internationalization implemetation for golang
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
.travis.yml
LICENSE
README.md
go.mod
go.sum
handler.go
handler_test.go
store.go
store_test.go
translator.go
translator_test.go

README.md

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.

You can’t perform that action at this time.