~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/chai2010/gettext-go/README.md

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
gettext-go
2
 
==========
3
 
 
4
 
PkgDoc: [http://godoc.org/github.com/chai2010/gettext-go/gettext](http://godoc.org/github.com/chai2010/gettext-go/gettext)
5
 
 
6
 
Install
7
 
========
8
 
 
9
 
1. `go get github.com/chai2010/gettext-go/gettext`
10
 
2. `go run hello.go`
11
 
 
12
 
The godoc.org or gowalker.org has more information.
13
 
 
14
 
Example
15
 
=======
16
 
 
17
 
```Go
18
 
package main
19
 
 
20
 
import (
21
 
        "fmt"
22
 
 
23
 
        "github.com/chai2010/gettext-go/gettext"
24
 
)
25
 
 
26
 
func main() {
27
 
        gettext.SetLocale("zh_CN")
28
 
        gettext.Textdomain("hello")
29
 
 
30
 
        gettext.BindTextdomain("hello", "local", nil)
31
 
 
32
 
        // gettext.BindTextdomain("hello", "local", nil)         // from local dir
33
 
        // gettext.BindTextdomain("hello", "local.zip", nil)     // from local zip file
34
 
        // gettext.BindTextdomain("hello", "local.zip", zipData) // from embedded zip data
35
 
 
36
 
        // translate source text
37
 
        fmt.Println(gettext.Gettext("Hello, world!"))
38
 
        // Output: 你好, 世界!
39
 
 
40
 
        // translate resource
41
 
        fmt.Println(string(gettext.Getdata("poems.txt"))))
42
 
        // Output: ...
43
 
}
44
 
```
45
 
 
46
 
Go file: [hello.go](https://github.com/chai2010/gettext-go/blob/master/examples/hello.go); PO file: [hello.po](https://github.com/chai2010/gettext-go/blob/master/examples/local/default/LC_MESSAGES/hello.po);
47
 
 
48
 
BUGS
49
 
====
50
 
 
51
 
Please report bugs to <chaishushan@gmail.com>.
52
 
 
53
 
Thanks!