summaryrefslogtreecommitdiffstats
path: root/i18n
diff options
context:
space:
mode:
authorAlbert Nigmatzianov <albertnigma@gmail.com>2017-05-03 09:11:25 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-05-03 09:23:13 +0200
commitcce49997a4f272b508ee98b83d40b087d0acf9e3 (patch)
treee2c0a2988d8c8f631673e6024f44359b9c993741 /i18n
parent3dd949d956390478da83b44488b0a5f4a9ebeb86 (diff)
i18n: Add tests
Diffstat (limited to 'i18n')
-rw-r--r--i18n/i18n_test.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/i18n/i18n_test.go b/i18n/i18n_test.go
index 157c478d8..63e09ec8a 100644
--- a/i18n/i18n_test.go
+++ b/i18n/i18n_test.go
@@ -64,7 +64,7 @@ var i18nTests = []i18nTest{
// Translation missing in default language but present in current
{
data: map[string][]byte{
- "en.toml": []byte("[goodybe]\nother = \"Goodbye, World!\""),
+ "en.toml": []byte("[goodbye]\nother = \"Goodbye, World!\""),
"es.toml": []byte("[hello]\nother = \"¡Hola, Mundo!\""),
},
args: nil,
@@ -112,6 +112,31 @@ var i18nTests = []i18nTest{
expected: "¡Hola, 50 gente!",
expectedFlag: "¡Hola, 50 gente!",
},
+ // Same id and translation in current language
+ // https://github.com/spf13/hugo/issues/2607
+ {
+ data: map[string][]byte{
+ "es.toml": []byte("[hello]\nother = \"hello\""),
+ "en.toml": []byte("[hello]\nother = \"hi\""),
+ },
+ args: nil,
+ lang: "es",
+ id: "hello",
+ expected: "hello",
+ expectedFlag: "hello",
+ },
+ // Translation missing in current language, but same id and translation in default
+ {
+ data: map[string][]byte{
+ "es.toml": []byte("[bye]\nother = \"bye\""),
+ "en.toml": []byte("[hello]\nother = \"hello\""),
+ },
+ args: nil,
+ lang: "es",
+ id: "hello",
+ expected: "hello",
+ expectedFlag: "[i18n] hello",
+ },
}
func doTestI18nTranslate(t *testing.T, test i18nTest, cfg config.Provider) string {