aboutsummaryrefslogtreecommitdiff
path: root/examples/gettext.go
diff options
context:
space:
mode:
authorJosé Carlos Nieto <xiam@menteslibres.org>2012-10-06 16:07:42 -0500
committerJosé Carlos Nieto <xiam@menteslibres.org>2012-10-06 16:07:42 -0500
commitf7f4bcdaad57ce74a2b0e32c771d30178e0b14e1 (patch)
treea28a5a3622436028ae93185a2cb603efa05464ad /examples/gettext.go
parentInitial commit. (diff)
downloadgotext-f7f4bcdaad57ce74a2b0e32c771d30178e0b14e1.tar.gz
gotext-f7f4bcdaad57ce74a2b0e32c771d30178e0b14e1.tar.xz
Adding Deutsch and Español examples.
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!"))
+}
+