aboutsummaryrefslogtreecommitdiff
path: root/gettext_test.go
diff options
context:
space:
mode:
authorJosé Carlos <jose.carlos@menteslibres.net>2016-01-09 09:06:46 -0600
committerJosé Carlos <jose.carlos@menteslibres.net>2016-01-09 09:06:46 -0600
commitea286668e74dbb65abeea59f0c51f00cd8df3c73 (patch)
treeb291ecbcd587165c27a3fd16162019daf924348f /gettext_test.go
parentStyling typos. (diff)
parentFix translations with DGettext (and other D... func) when the domain name is ... (diff)
downloadgotext-ea286668e74dbb65abeea59f0c51f00cd8df3c73.tar.gz
gotext-ea286668e74dbb65abeea59f0c51f00cd8df3c73.tar.xz
Merge pull request #2 from sqp/nil_string
Fix translations with DGettext (and other D... func) when the domain name is empty.
Diffstat (limited to 'gettext_test.go')
-rw-r--r--gettext_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/gettext_test.go b/gettext_test.go
index b651152..8e88180 100644
--- a/gettext_test.go
+++ b/gettext_test.go
@@ -128,3 +128,36 @@ func TestGermanDeutschland(t *testing.T) {
}
}
+
+func TestDGettextFallback(t *testing.T) {
+ os.Setenv("LANGUAGE", "de_DE.utf8")
+
+ SetLocale(LC_ALL, "")
+ BindTextdomain("example", "./examples/")
+ Textdomain("example")
+
+ t1 := DGettext("", "Hello, world!")
+
+ fmt.Println(t1)
+
+ if t1 != "Hallo, Welt!" {
+ t.Errorf("Failed translation fallback.")
+ }
+
+ t2 := Sprintf(DNGettext("", "An apple", "%d apples", 1), 1, "garbage")
+
+ fmt.Println(t2)
+
+ if t2 != "Ein Apfel" {
+ t.Errorf("Failed translation fallback.")
+ }
+
+ t3 := Sprintf(DNGettext("", "An apple", "%d apples", 3), 3)
+
+ fmt.Println(t3)
+
+ if t3 != "3 Äpfel" {
+ t.Errorf("Failed translation fallback.")
+ }
+
+}