i9n is an easy and powerful golang module make your i18n work twice faster, namely i9n
.
- no need write i18n resource files, use
i9n.Printf
and generate them by one command. - support go-zero, gin out of box, other frameworks by plugins
→ go run cmd/main.go -l ch
用戶您好, 你要 1 个苹果还是 2 两个苹果?
→ go run cmd/main.go -l en
hi, customer. 1 apple or 2 apples?
go has built in support for i18n at https://github.com/golang/text.git, the baisc idea is:
- extract strings need to be translated in source code
- generate resources and translate them by someone
- load these resource
- manually rewrite or use
gotext rewrite
to replacefmt.Print
withmessage.Printer
see gotext
branch, which works after build but has issue when run go run main.go
directly