{"id":"dda0985b928d345b","repo":"gohugoio/hugo","slug":"failed-to-load-translations-w-s","errorCode":null,"errorMessage":"failed to load translations: %w%s","messagePattern":"failed to load translations: %w(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"langs/i18n/translationProvider.go","lineNumber":142,"sourceCode":"\t\t}\n\t\tname = artificialLangTagPrefix + name\n\t}\n\n\t_, err = bundle.ParseMessageFileBytes(b, name)\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"no plural rule\") {\n\t\t\t// https://github.com/gohugoio/hugo/issues/7798\n\t\t\tname = artificialLangTagPrefix + name\n\t\t\t_, err = bundle.ParseMessageFileBytes(b, name)\n\t\t\tif err == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\tvar guidance string\n\t\tif strings.Contains(err.Error(), \"mixed with unreserved keys\") {\n\t\t\tguidance = \": see the lang.Translate documentation for a list of reserved keys\"\n\t\t}\n\t\treturn errWithFileContext(fmt.Errorf(\"failed to load translations: %w%s\", err, guidance), r)\n\t}\n\n\treturn nil\n}\n\n// CloneResource sets the language func for the new language.\nfunc (tp *TranslationProvider) CloneResource(dst, src *deps.Deps) error {\n\tdst.Translate = tp.getTranslateFunc(dst)\n\treturn nil\n}\n\nfunc defaultLanguage(conf config.AllProvider) *langs.Language {\n\tkey := conf.DefaultContentLanguage()\n\tfor _, l := range conf.Languages().(langs.Languages) {\n\t\tif l.Lang == key {\n\t\t\treturn l\n\t\t}\n\t}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/langs/i18n/translationProvider.go#L124-L160","documentation":"Hugo's i18n TranslationProvider failed to parse a translation file with go-i18n's bundle.ParseMessageFileBytes. The wrapped error carries the underlying parse failure (invalid TOML/YAML/JSON, bad plural categories, or reserved keys mixed with unreserved keys), and Hugo appends extra guidance for the reserved-keys case. The error is wrapped with file context so the offending i18n file and position are shown.","triggerScenarios":"Loading any file under i18n/ (or a theme's i18n/) during site build. Specifically: syntax errors in the translation file; using reserved go-i18n keys (id, description, one, other, few, many, zero) mixed with custom sub-keys under one message; plural categories not valid for the file's language tag (Hugo retries with an artificial 'art-x-' tag prefix for the 'no plural rule' case, so this fires only when that retry also fails).","commonSituations":"Nesting custom keys alongside 'one'/'other' under a translation id; copying plural forms (e.g. 'few', 'many') into a language whose CLDR plural rules don't define them; malformed TOML/YAML after hand-editing; theme-provided i18n files incompatible after a go-i18n or Hugo upgrade; naming the file with an unparseable language code.","solutions":["Open the i18n file named in the error and fix the reported syntax/key problem at the given position.","If the message mentions 'mixed with unreserved keys', restructure the entry: reserved plural keys (one, other, etc.) cannot share a map with arbitrary custom keys — see the lang.Translate docs for the reserved-key list.","Remove plural categories not supported by that language's CLDR rules, or rename the file to the correct language code.","Validate the file's TOML/YAML/JSON with a linter to catch format errors."],"exampleFix":"# i18n/en.toml — before (reserved plural keys mixed with custom keys)\n[readMore]\nother = \"Read more\"\nlabel = \"link\"\n\n# after\n[readMore]\nother = \"Read more\"\n\n[readMoreLabel]\nother = \"link\"","handlingStrategy":"validation","validationCode":"// Validate translation files parse before running hugo\n// ls i18n/ && for f in i18n/*.toml; do tomlv \"$f\"; done\nif _, err := toml.DecodeFile(\"i18n/en.toml\", &v); err != nil { log.Fatal(err) }","typeGuard":null,"tryCatchPattern":"if err := ss.Update(deps); err != nil {\n    if strings.Contains(err.Error(), \"failed to load translations\") {\n        // report offending i18n file/key to user\n    }\n    return err\n}","preventionTips":["Lint i18n TOML/YAML/JSON files in CI before builds","Keep translation keys flat and consistently typed across languages","Avoid duplicate keys and reserved plural keys like 'other' misuse","Validate new language files locally with hugo server before commit"],"tags":["i18n","translations","toml","yaml","hugo","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}