diff options
Diffstat (limited to 'langs/language.go')
-rw-r--r-- | langs/language.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/langs/language.go b/langs/language.go index 14e3263ae..f71b0255b 100644 --- a/langs/language.go +++ b/langs/language.go @@ -78,12 +78,7 @@ func NewLanguage(lang string, cfg config.Provider) *Language { } maps.ToLower(params) - defaultContentDir := cfg.GetString("contentDir") - if defaultContentDir == "" { - panic("contentDir not set") - } - - l := &Language{Lang: lang, ContentDir: defaultContentDir, Cfg: cfg, params: params, settings: make(map[string]interface{})} + l := &Language{Lang: lang, ContentDir: cfg.GetString("contentDir"), Cfg: cfg, params: params, settings: make(map[string]interface{})} return l } @@ -132,6 +127,24 @@ func (l *Language) Params() map[string]interface{} { return l.params } +func (l Languages) AsSet() map[string]bool { + m := make(map[string]bool) + for _, lang := range l { + m[lang.Lang] = true + } + + return m +} + +func (l Languages) AsOrdinalSet() map[string]int { + m := make(map[string]int) + for i, lang := range l { + m[lang.Lang] = i + } + + return m +} + // IsMultihost returns whether there are more than one language and at least one of // the languages has baseURL specificed on the language level. func (l Languages) IsMultihost() bool { |