gettext-goGo 語(yǔ)言實(shí)現(xiàn)的 gettext 支持庫(kù)
Gettext 用于系統(tǒng)的國(guó)際化(I18N)和本地化(L10N),可以在編譯程序的時(shí)候使用本國(guó)語(yǔ)言支持(Native Language Support(NLS)),其可以使程序的輸出使用用戶(hù)設(shè)置.
而 gettext-go 是完全采用 Go 語(yǔ)言實(shí)現(xiàn)的 gettext 支持庫(kù).
示例代碼:
// Copyright 2013 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"code.google.com/p/gettext-go/gettext"
)
func main() {
gettext.SetLocale("zh_CN")
gettext.BindTextdomain("hello", "local")
gettext.Textdomain("hello")
fmt.Println(gettext.Gettext("Hello, world!"))
// Output: 你好, 世界!
}評(píng)論
圖片
表情
