diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-07-26 10:24:27 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-06 18:32:16 +0300 |
commit | 75dd596e6c38466fcb97a8b9dc9eb20fc2fb7fd6 (patch) | |
tree | 37f43d8af433033996fbae9d2b3914888144c60a /commands/multilingual.go | |
parent | 618948e4a83665f8355b01d8a3f7a7186e6bd3eb (diff) |
Introduce HugoSites type
And a Hugo global variable which contains the site under build.
This is really needed to get some level of control of the "multiple languages" in play.
There are still work related to this scattered around, but that will come.
With this commit, the multilingual feature is starting to work.
Diffstat (limited to 'commands/multilingual.go')
-rw-r--r-- | commands/multilingual.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/commands/multilingual.go b/commands/multilingual.go index 3f813474d..9afb562ba 100644 --- a/commands/multilingual.go +++ b/commands/multilingual.go @@ -11,24 +11,30 @@ import ( "github.com/spf13/viper" ) -var langConfigsList hugolib.Languages - -func readMultilingualConfiguration() error { +func readMultilingualConfiguration() (HugoSites, error) { + h := make(HugoSites, 0) multilingual := viper.GetStringMap("Multilingual") if len(multilingual) == 0 { // TODO(bep) multilingo langConfigsList = append(langConfigsList, hugolib.NewLanguage("en")) - return nil + h = append(h, hugolib.NewSite(hugolib.NewLanguage("en"))) + return h, nil } var err error - langConfigsList, err = toSortedLanguages(multilingual) + langConfigsList, err := toSortedLanguages(multilingual) if err != nil { - return fmt.Errorf("Failed to parse multilingual config: %s", err) + return nil, fmt.Errorf("Failed to parse multilingual config: %s", err) + } + + for _, lang := range langConfigsList { + s := hugolib.NewSite(lang) + s.SetMultilingualConfig(lang, langConfigsList) + h = append(h, s) } - return nil + return h, nil } func toSortedLanguages(l map[string]interface{}) (hugolib.Languages, error) { |