summaryrefslogtreecommitdiffstats
path: root/hugolib/multilingual.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-08-05 13:10:58 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-06 18:32:17 +0300
commit90de511017f9dcc65cccd7d161c70f326df3ab5b (patch)
tree072938c9f0c982b6464a96954468fbbfd6afd63d /hugolib/multilingual.go
parent36f2a1f676c6e8821d2d1600c696dcb2658d1cc9 (diff)
Make taxonomies configurable per language
See #2312
Diffstat (limited to 'hugolib/multilingual.go')
-rw-r--r--hugolib/multilingual.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/hugolib/multilingual.go b/hugolib/multilingual.go
index 0bcc2a697..8bc7bea33 100644
--- a/hugolib/multilingual.go
+++ b/hugolib/multilingual.go
@@ -6,6 +6,8 @@ import (
"sort"
"strings"
+ "fmt"
+
"github.com/spf13/cast"
"github.com/spf13/viper"
)
@@ -112,3 +114,39 @@ func (s *Site) currentLanguageString() string {
func (s *Site) currentLanguage() *Language {
return s.Language
}
+
+func toSortedLanguages(l map[string]interface{}) (Languages, error) {
+ langs := make(Languages, len(l))
+ i := 0
+
+ for lang, langConf := range l {
+ langsMap, ok := langConf.(map[string]interface{})
+
+ if !ok {
+ return nil, fmt.Errorf("Language config is not a map: %v", langsMap)
+ }
+
+ language := NewLanguage(lang)
+
+ for k, v := range langsMap {
+ loki := strings.ToLower(k)
+ switch loki {
+ case "title":
+ language.Title = cast.ToString(v)
+ case "weight":
+ language.Weight = cast.ToInt(v)
+ }
+
+ // Put all into the Params map
+ // TODO(bep) reconsile with the type handling etc. from other params handlers.
+ language.SetParam(loki, v)
+ }
+
+ langs[i] = language
+ i++
+ }
+
+ sort.Sort(langs)
+
+ return langs, nil
+}