aboutsummaryrefslogtreecommitdiff
path: root/_examples/gettext.go
diff options
context:
space:
mode:
authorJosé Carlos Nieto <jose.carlos@menteslibres.net>2016-02-20 07:29:59 -0600
committerJosé Carlos Nieto <jose.carlos@menteslibres.net>2016-02-20 07:29:59 -0600
commit5269cf26ba096845b4a62901b7b1ebb49781177a (patch)
tree0121d74371e218ee5f37d0b5ed3be0993ed89ffc /_examples/gettext.go
parentMerge pull request #6 from mvo5/feature/xgettext (diff)
downloadgotext-5269cf26ba096845b4a62901b7b1ebb49781177a.tar.gz
gotext-5269cf26ba096845b4a62901b7b1ebb49781177a.tar.xz
Code cleaning.
Diffstat (limited to '_examples/gettext.go')
-rw-r--r--_examples/gettext.go31
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!"))
+}
+