...

Source file src/github.com/chai2010/gettext-go/hello.go

Documentation: github.com/chai2010/gettext-go

     1  // Copyright 2013 <chaishushan{AT}gmail.com>. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build ignore
     6  
     7  package main
     8  
     9  import (
    10  	"fmt"
    11  
    12  	"github.com/chai2010/gettext-go"
    13  )
    14  
    15  func main() {
    16  	gettext.SetLanguage("zh_CN")
    17  	gettext.BindLocale(gettext.New("hello", "./examples/locale"))
    18  
    19  	fmt.Println(gettext.Gettext("Hello, world!"))
    20  
    21  	// Output:
    22  	// 你好, 世界!
    23  
    24  	func() {
    25  		gettext := gettext.New("hello", "./examples/locale").SetLanguage("zh_TW")
    26  		fmt.Println(gettext.PGettext("main.func", "Gettext in func."))
    27  
    28  		// Output:
    29  		// 閉包函數中的Gettext.(ctx:main.func)
    30  	}()
    31  }
    32  

View as plain text