diff options
author | José Carlos <jose.carlos@menteslibres.net> | 2016-02-20 07:33:14 -0600 |
---|---|---|
committer | José Carlos <jose.carlos@menteslibres.net> | 2016-02-20 07:33:14 -0600 |
commit | ea584c8c09c390260b68a9e1a15d60f7ffe480c5 (patch) | |
tree | d84ea7ec068b7998adae2bd4580db9dc78584c56 /_examples/gettext.go | |
parent | Merge branch 'master' of github.com:gosexy/gettext (diff) | |
parent | Code cleaning. (diff) | |
download | gotext-ea584c8c09c390260b68a9e1a15d60f7ffe480c5.tar.gz gotext-ea584c8c09c390260b68a9e1a15d60f7ffe480c5.tar.xz |
Merge pull request #9 from gosexy/issue-5
Code cleaning.
Diffstat (limited to '_examples/gettext.go')
-rw-r--r-- | _examples/gettext.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/_examples/gettext.go b/_examples/gettext.go new file mode 100644 index 0000000..a01e0d5 --- /dev/null +++ b/_examples/gettext.go @@ -0,0 +1,31 @@ +package main + +import ( + "github.com/gosexy/gettext" + "fmt" + "os" +) + +func main() { + gettext.BindTextdomain("example", ".") + gettext.Textdomain("example") + + os.Setenv("LANGUAGE", "es_MX.utf8") + + gettext.SetLocale(gettext.LC_ALL, "") + + fmt.Println(gettext.Gettext("Hello, world!")) + + os.Setenv("LANGUAGE", "de_DE.utf8") + + gettext.SetLocale(gettext.LC_ALL, "") + + fmt.Println(gettext.Gettext("Hello, world!")) + + os.Setenv("LANGUAGE", "en_US.utf8") + + gettext.SetLocale(gettext.LC_ALL, "") + + fmt.Println(gettext.Gettext("Hello, world!")) +} + |