aboutsummaryrefslogtreecommitdiff
path: root/examples/gettext.go
blob: a01e0d5c0c0b56b176bde4410d3b0ca191c5350e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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!"))
}