diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-30 17:51:18 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-01-30 18:53:07 +0100 |
commit | ae742cb1bdf35b81aa0ede5453da6b0c4a4fccf2 (patch) | |
tree | f2922d4343f9819e7ff4220ebc333b467c8f0d4b /helpers/language_test.go | |
parent | feeed073c3320b09fb38168ce272ac88b987f1d2 (diff) |
Fix language params handling
This fixes some issues with language params handling by separating params from configuration values per language.
This means that you can now do this:
```toml
[languages]
[languages.en]
languageName = "English"
weight = 1
title = "My Cool Site"
[languages.en.params]
myParam = "Hi!"
```
This is not a breaking change, but the above is a less suprising way of configuring custom params.
It also fixes some hard-to-debug corner-cases in multilingual sites.
Fixes #4356
Fixes #4352
Diffstat (limited to 'helpers/language_test.go')
-rw-r--r-- | helpers/language_test.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/helpers/language_test.go b/helpers/language_test.go index 902177e1a..68ee3506d 100644 --- a/helpers/language_test.go +++ b/helpers/language_test.go @@ -23,11 +23,24 @@ import ( func TestGetGlobalOnlySetting(t *testing.T) { v := viper.New() lang := NewDefaultLanguage(v) - lang.SetParam("defaultContentLanguageInSubdir", false) - lang.SetParam("paginatePath", "side") + lang.Set("defaultContentLanguageInSubdir", false) + lang.Set("paginatePath", "side") v.Set("defaultContentLanguageInSubdir", true) v.Set("paginatePath", "page") require.True(t, lang.GetBool("defaultContentLanguageInSubdir")) require.Equal(t, "side", lang.GetString("paginatePath")) } + +func TestLanguageParams(t *testing.T) { + assert := require.New(t) + + v := viper.New() + v.Set("p1", "p1cfg") + + lang := NewDefaultLanguage(v) + lang.SetParam("p1", "p1p") + + assert.Equal("p1p", lang.Params()["p1"]) + assert.Equal("p1cfg", lang.Get("p1")) +} |