1Panel-dev/1Panel · critical

[i18n] failed to init language files, See log above for deta

Error message

[i18n] failed to init language files, See log above for details

What it means

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.

Source

Thrown at core/i18n/i18n.go:253

		lang = defaultLang
	}
	cachedDBLang.Store(lang)
}

func initBundle() {
	bundle = i18n.NewBundle(language.Chinese)
	bundle.RegisterUnmarshalFunc("yaml", yaml.Unmarshal)

	isSuccess := true
	for _, file := range langFiles {
		if _, err := bundle.LoadMessageFileFS(fs, file); err != nil {
			fmt.Printf("[i18n] load language file %s failed: %v\n", file, err)
			isSuccess = false
		}
	}

	if !isSuccess {
		panic("[i18n] failed to init language files, See log above for details")
	}
}

View on GitHub (pinned to 5ac7c80881)

Solutions

  1. Read the '[i18n] load language file ...' lines just above the panic — they name the exact file and error
  2. Fix that YAML (yaml-lint it, remove duplicate top-level message keys), then rebuild the core binary
  3. In CI, validate all locales/*.yaml (parse + duplicate-key check) before building

Example fix

# before: locales/en.yaml has duplicate key
Settings:
  title: A
Settings:
  desc: B
# after
Settings:
  title: A
  desc: B
Defensive patterns

Strategy: validation

Validate before calling

# CI: every locale file must parse and have unique top-level keys
python3 - <<'PY'
import glob, sys, yaml
class NoDupLoader(yaml.SafeLoader): pass
def no_dup(loader, node, deep=False):
    seen = set()
    for k,_ in loader.construct_pairs(node, deep=deep):
        if k in seen: raise ValueError(f"duplicate key {k}")
        seen.add(k)
    return dict()
NoDupLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, no_dup)
for f in glob.glob('core/i18n/*/locales/**/*.yaml', recursive=True):
    yaml.load(open(f), Loader=NoDupLoader)
print('locales ok')
PY

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of 1Panel-dev/1Panel@5ac7c80881 (2026-08-15). Data as JSON: /api/errors/418dfdd5776c5560. Report an issue: GitHub.