mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 05:30:54 +03:00
Add a way to disable one or more languages
This commit adds a new config setting: ```toml disableLanguages = ["fr"] ``` If this is a multilingual site: * No site for the French language will be created * French content pages will be ignored/not read * The French language configuration (menus etc.) will also be ignored This makes it possible to start translating new languages and turn it on when you're happy etc. Fixes #4297 Fixed #4329
This commit is contained in:
parent
322c567220
commit
6413559f75
10 changed files with 160 additions and 42 deletions
|
@ -35,6 +35,7 @@ type SourceSpec struct {
|
|||
|
||||
Languages map[string]interface{}
|
||||
DefaultContentLanguage string
|
||||
DisabledLanguages map[string]bool
|
||||
}
|
||||
|
||||
// NewSourceSpec initializes SourceSpec using languages from a given configuration.
|
||||
|
@ -42,6 +43,12 @@ func NewSourceSpec(cfg config.Provider, fs *hugofs.Fs) *SourceSpec {
|
|||
defaultLang := cfg.GetString("defaultContentLanguage")
|
||||
languages := cfg.GetStringMap("languages")
|
||||
|
||||
disabledLangsSet := make(map[string]bool)
|
||||
|
||||
for _, disabledLang := range cfg.GetStringSlice("disableLanguages") {
|
||||
disabledLangsSet[disabledLang] = true
|
||||
}
|
||||
|
||||
if len(languages) == 0 {
|
||||
l := helpers.NewDefaultLanguage(cfg)
|
||||
languages[l.Lang] = l
|
||||
|
@ -62,7 +69,7 @@ func NewSourceSpec(cfg config.Provider, fs *hugofs.Fs) *SourceSpec {
|
|||
}
|
||||
}
|
||||
|
||||
return &SourceSpec{ignoreFilesRe: regexps, Cfg: cfg, Fs: fs, Languages: languages, DefaultContentLanguage: defaultLang}
|
||||
return &SourceSpec{ignoreFilesRe: regexps, Cfg: cfg, Fs: fs, Languages: languages, DefaultContentLanguage: defaultLang, DisabledLanguages: disabledLangsSet}
|
||||
}
|
||||
|
||||
func (s *SourceSpec) IgnoreFile(filename string) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue