mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-23 07:11:29 +00:00
i18n: Add tests
This commit is contained in:
parent
3dd949d956
commit
cce49997a4
1 changed files with 26 additions and 1 deletions
|
@ -64,7 +64,7 @@ var i18nTests = []i18nTest{
|
||||||
// Translation missing in default language but present in current
|
// Translation missing in default language but present in current
|
||||||
{
|
{
|
||||||
data: map[string][]byte{
|
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!\""),
|
"es.toml": []byte("[hello]\nother = \"¡Hola, Mundo!\""),
|
||||||
},
|
},
|
||||||
args: nil,
|
args: nil,
|
||||||
|
@ -112,6 +112,31 @@ var i18nTests = []i18nTest{
|
||||||
expected: "¡Hola, 50 gente!",
|
expected: "¡Hola, 50 gente!",
|
||||||
expectedFlag: "¡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 {
|
func doTestI18nTranslate(t *testing.T, test i18nTest, cfg config.Provider) string {
|
||||||
|
|
Loading…
Reference in a new issue