diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-07-28 10:30:58 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-06 18:32:16 +0300 |
commit | 708bc78770a0b0361908f6404f57264c53252a95 (patch) | |
tree | 9b7e3a05b1e83a768bfa0dd96b61b07dd7917cfd /hugolib/multilingual.go | |
parent | f023dfd7636f73b11c94e86a05c6273941d52c58 (diff) |
Optimize the multilanguage build process
Work In Progress!
This commit makes a rework of the build and rebuild process to better suit a multi-site setup.
This also includes a complete overhaul of the site tests. Previous these were a messy mix that
were testing just small parts of the build chain, some of it testing code-paths not even used in
"real life". Now all tests that depends on a built site follows the same and real production code path.
See #2309
Closes #2211
Closes #477
Closes #1744
Diffstat (limited to 'hugolib/multilingual.go')
-rw-r--r-- | hugolib/multilingual.go | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/hugolib/multilingual.go b/hugolib/multilingual.go index c75f504ef..0bcc2a697 100644 --- a/hugolib/multilingual.go +++ b/hugolib/multilingual.go @@ -45,6 +45,8 @@ func (l Languages) Swap(i, j int) { l[i], l[j] = l[j], l[i] } type Multilingual struct { Languages Languages + DefaultLang *Language + langMap map[string]*Language langMapInit sync.Once } @@ -60,7 +62,7 @@ func (ml *Multilingual) Language(lang string) *Language { } func (ml *Multilingual) enabled() bool { - return len(ml.Languages) > 0 + return len(ml.Languages) > 1 } func (l *Language) Params() map[string]interface{} { @@ -98,16 +100,6 @@ func (l *Language) Get(key string) interface{} { return viper.Get(key) } -// TODO(bep) multilingo move this to a constructor. -func (s *Site) SetMultilingualConfig(currentLang *Language, languages Languages) { - - ml := &Multilingual{ - Languages: languages, - } - viper.Set("Multilingual", ml.enabled()) - s.Multilingual = ml -} - func (s *Site) multilingualEnabled() bool { return s.Multilingual != nil && s.Multilingual.enabled() } @@ -118,5 +110,5 @@ func (s *Site) currentLanguageString() string { } func (s *Site) currentLanguage() *Language { - return s.Lang + return s.Language } |