gettext-goGo 语言实现的 gettext 支持库
Gettext 用于系统的国际化(I18N)和本地化(L10N),可以在编译程序的时候使用本国语言支持(Native Language Support(NLS)),其可以使程序的输出使用用户设置.
而 gettext-go 是完全采用 Go 语言实现的 gettext 支持库.
示例代码:
// 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: 你好, 世界!
}评论
