aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/api-usage/gotext.go
blob: 7ea7119606c5f45b9e81ac1439c94ad3a62b72aa (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gotext

import (
	"os"

	g "gobang"
)



func MainTest() {
	g.Init()
	Init("tests", "locale/")

	g.Testing("Español", func() {
		os.Setenv("LANGUAGE", "es_MX.UTF-8")
		SetLocale(LC_ALL, "")

		g.TAssertEqual(Gettext("Hello, world!"), "¡Hola, mundo!")
		g.TAssertEqual(Gettext("Good morning"),  "Buenos días")
		g.TAssertEqual(Gettext("Good bye!"),     "¡Hasta luego!")
		g.TAssertEqual(Sprintf(
			NGettext("An apple", "%d apples", 1),
			1,
			"garbage",
		), "Una manzana")
		g.TAssertEqual(Sprintf(
			NGettext("An apple", "%d apples", 3),
			3,
		), "3 manzanas")
	})

	g.Testing("Deutsch", func() {
		os.Setenv("LANGUAGE", "de_DE.UTF-8")
		SetLocale(LC_ALL, "")

		g.TAssertEqual(Gettext("Hello, world!"), "Hallo, Welt!")
		g.TAssertEqual(Gettext("Good morning"),  "Guten Morgen")
		g.TAssertEqual(Gettext("Good bye!"),     "Auf Wiedersehen!")
		g.TAssertEqual(Sprintf(
			NGettext("An apple", "%d apples", 1),
			1,
			"garbage",
		), "Ein Apfel")
		g.TAssertEqual(Sprintf(
			NGettext("An apple", "%d apples", 3),
			3,
		), "3 Äpfel")
	})

	g.Testing("Français", func() {
		os.Setenv("LANGUAGE", "fr_FR.UTF-8")
		SetLocale(LC_ALL, "")

		g.TAssertEqual(Gettext("Hello, world!"), "Hello, world!")
		g.TAssertEqual(Gettext("Good morning"),  "Good morning")
		g.TAssertEqual(Gettext("Good bye!"),     "Good bye!")
		g.TAssertEqual(Sprintf(
			NGettext("An apple", "%d apples", 1),
			1,
			"garbage",
		), "An apple")
		g.TAssertEqual(Sprintf(
			NGettext("An apple", "%d apples", 3),
			3,
		), "3 apples")
	})
}