i18n is a Macaron middleware for internationalization using gettext.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Dashie der otter 39b6db0ec3
Switch to gotext
7 months ago
example Move to root dir 7 months ago
README.md Switch to gotext 7 months ago
i18n.go Switch to gotext 7 months ago
i18n_test.go lol like I know what I'm doing 7 months ago

README.md

i18n

i18n is a Macaron middleware for internationalization.

Support po/mo file, use gotext.

Usage

main.go

package main

import (
	"github.com/chai2010/gettext-go/gettext"
	"github.com/go-macaron/macaron"
	"github.com/yetist/middleware/i18n"
)

func __(msgid string) string {
	return gettext.PGettext("", msgid)
}

func main() {
	m := macaron.Classic()
	m.Use(i18n.I18n(i18n.Options{
		Domain:    "example",
		Parameter: "lang",
	}))
	m.Get("/", func() string {
		return __("Hello world!")
	})
	m.Run()
}

directories:

locale/
├── en_US
│   └── LC_MESSAGES
│       ├── example.mo
│       └── example.po
├── zh_CN
│   └── LC_MESSAGES
│       ├── example.mo
│       └── example.po
└── zh_TW
    └── LC_MESSAGES
        ├── example.mo
	└── example.po