diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-07-28 09:30:58 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-06 18:32:16 +0300 |
commit | 708bc78770a0b0361908f6404f57264c53252a95 (patch) | |
tree | 9b7e3a05b1e83a768bfa0dd96b61b07dd7917cfd /commands/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 'commands/multilingual.go')
-rw-r--r-- | commands/multilingual.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/commands/multilingual.go b/commands/multilingual.go index 7c43d15bc..4d0f6e107 100644 --- a/commands/multilingual.go +++ b/commands/multilingual.go @@ -11,30 +11,31 @@ import ( "github.com/spf13/viper" ) -func readMultilingualConfiguration() (hugolib.HugoSites, error) { - h := make(hugolib.HugoSites, 0) +func readMultilingualConfiguration() (*hugolib.HugoSites, error) { + sites := make([]*hugolib.Site, 0) multilingual := viper.GetStringMap("Multilingual") if len(multilingual) == 0 { // TODO(bep) multilingo langConfigsList = append(langConfigsList, hugolib.NewLanguage("en")) - h = append(h, hugolib.NewSite(hugolib.NewLanguage("en"))) - return h, nil + sites = append(sites, hugolib.NewSite(hugolib.NewLanguage("en"))) } - var err error + if len(multilingual) > 0 { + var err error - langConfigsList, err := toSortedLanguages(multilingual) + languages, err := toSortedLanguages(multilingual) - if err != nil { - return nil, fmt.Errorf("Failed to parse multilingual config: %s", err) - } + if err != nil { + return nil, fmt.Errorf("Failed to parse multilingual config: %s", err) + } + + for _, lang := range languages { + sites = append(sites, hugolib.NewSite(lang)) + } - for _, lang := range langConfigsList { - s := hugolib.NewSite(lang) - s.SetMultilingualConfig(lang, langConfigsList) - h = append(h, s) } - return h, nil + return hugolib.NewHugoSites(sites...) + } func toSortedLanguages(l map[string]interface{}) (hugolib.Languages, error) { |