From f7f4bcdaad57ce74a2b0e32c771d30178e0b14e1 Mon Sep 17 00:00:00 2001 From: José Carlos Nieto Date: Sat, 6 Oct 2012 16:07:42 -0500 Subject: Adding Deutsch and Español examples. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/gettext.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/gettext.go (limited to 'examples/gettext.go') 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!")) +} + -- cgit v1.2.3