{"record":{"id":"418dfdd5776c5560","repo":"1Panel-dev/1Panel","slug":"i18n-failed-to-init-language-files-see-log-abov","errorCode":null,"errorMessage":"[i18n] failed to init language files, See log above for details","messagePattern":"\\[i18n\\] failed to init language files, See log above for details","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/i18n/i18n.go","lineNumber":253,"sourceCode":"\t\tlang = defaultLang\n\t}\n\tcachedDBLang.Store(lang)\n}\n\nfunc initBundle() {\n\tbundle = i18n.NewBundle(language.Chinese)\n\tbundle.RegisterUnmarshalFunc(\"yaml\", yaml.Unmarshal)\n\n\tisSuccess := true\n\tfor _, file := range langFiles {\n\t\tif _, err := bundle.LoadMessageFileFS(fs, file); err != nil {\n\t\t\tfmt.Printf(\"[i18n] load language file %s failed: %v\\n\", file, err)\n\t\t\tisSuccess = false\n\t\t}\n\t}\n\n\tif !isSuccess {\n\t\tpanic(\"[i18n] failed to init language files, See log above for details\")\n\t}\n}\n","sourceCodeStart":235,"sourceCodeEnd":256,"githubUrl":"https://github.com/1Panel-dev/1Panel/blob/5ac7c808815b0691009cd390414f03471312262f/core/i18n/i18n.go#L235-L256","documentation":"Panic at the end of i18n bundle init: one or more embedded language YAML files failed LoadMessageFileFS. Each failure is printed first ('[i18n] load language file %s failed: %v'); if any failed, this summary panic aborts core startup, since translations would be incomplete.","triggerScenarios":"core/i18n init loops over embedded langFiles (*.yaml under locales) calling bundle.LoadMessageFileFS; a file with invalid YAML, duplicate message IDs, or wrong extension makes err non-nil, sets isSuccess=false, and the panic fires after the loop.","commonSituations":"Contributing/editing a translation file with syntax errors or duplicate keys; build from a dirty tree with a broken locales file; go:embed picking up a stray non-i18n yaml in the locales dir.","solutions":["Read the '[i18n] load language file ...' lines just above the panic — they name the exact file and error","Fix that YAML (yaml-lint it, remove duplicate top-level message keys), then rebuild the core binary","In CI, validate all locales/*.yaml (parse + duplicate-key check) before building"],"exampleFix":"# before: locales/en.yaml has duplicate key\nSettings:\n  title: A\nSettings:\n  desc: B\n# after\nSettings:\n  title: A\n  desc: B","handlingStrategy":"validation","validationCode":"# CI: every locale file must parse and have unique top-level keys\npython3 - <<'PY'\nimport glob, sys, yaml\nclass NoDupLoader(yaml.SafeLoader): pass\ndef no_dup(loader, node, deep=False):\n    seen = set()\n    for k,_ in loader.construct_pairs(node, deep=deep):\n        if k in seen: raise ValueError(f\"duplicate key {k}\")\n        seen.add(k)\n    return dict()\nNoDupLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, no_dup)\nfor f in glob.glob('core/i18n/*/locales/**/*.yaml', recursive=True):\n    yaml.load(open(f), Loader=NoDupLoader)\nprint('locales ok')\nPY","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate all locale YAML (syntax + duplicate keys) in CI before building the core binary","Keep the locales directory free of non-translation yaml files that go:embed might pick up"],"tags":["i18n","yaml","embed","go","panic","build"],"backgroundTag":null,"analyzedSha":"5ac7c808815b0691009cd390414f03471312262f","analyzedAt":"2026-08-15T14:02:06.953Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}