langs/i18n: Fallback to defaultContentLanguage instead of English

Co-authored-by: 641bill <wo23636@126.com>

Fixes #9216
This commit is contained in:
Joe Mooring
2023-04-22 15:58:44 -07:00
committed by Bjørn Erik Pedersen
parent f1062519ae
commit 0cb6ca5906
2 changed files with 44 additions and 1 deletions

View File

@@ -48,7 +48,12 @@ func NewTranslationProvider() *TranslationProvider {
func (tp *TranslationProvider) Update(d *deps.Deps) error {
spec := source.NewSourceSpec(d.PathSpec, nil, nil)
bundle := i18n.NewBundle(language.English)
var defaultLangTag, err = language.Parse(d.Cfg.GetString("defaultContentLanguage"))
if err != nil {
defaultLangTag = language.English
}
bundle := i18n.NewBundle(defaultLangTag)
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
bundle.RegisterUnmarshalFunc("yaml", yaml.Unmarshal)
bundle.RegisterUnmarshalFunc("yml", yaml.Unmarshal)