apache/answer · critical

read i18n file failed: %s

Error message

read i18n file failed: %s

What it means

NewTranslator must read the mandatory i18n.yaml manifest from the bundle directory; on os.ReadFile failure it returns 'read i18n file failed: <err>'. Without this file language options and translations cannot be initialized.

Source

Thrown at internal/base/translator/provider.go:113

		content, err := yaml.Marshal(translation)
		if err != nil {
			log.Debugf("marshal translation content failed: %s %s", file.Name(), err)
			continue
		}

		// add translator use backend translation
		if err = myTran.AddTranslator(content, file.Name()); err != nil {
			log.Debugf("add translator failed: %s %s", file.Name(), err)
			reportTranslatorFormatError(file.Name(), buf)
			continue
		}
	}
	GlobalTrans = myTran.GlobalTrans

	i18nFile, err := os.ReadFile(filepath.Join(c.BundleDir, "i18n.yaml"))
	if err != nil {
		return nil, fmt.Errorf("read i18n file failed: %s", err)
	}

	s := struct {
		LangOption []*LangOption `yaml:"language_options"`
	}{}
	err = yaml.Unmarshal(i18nFile, &s)
	if err != nil {
		return nil, fmt.Errorf("i18n file parsing failed: %s", err)
	}
	LanguageOptions = s.LangOption
	for _, option := range LanguageOptions {
		option.Label = fmt.Sprintf("%s (%d%%)", option.Label, option.Progress)
	}
	return GlobalTrans, err
}

// CheckLanguageIsValid check user input language is valid
func CheckLanguageIsValid(lang string) bool {

View on GitHub (pinned to 3b9f137061)

Solutions

  1. Ensure i18n.yaml exists at the configured BundleDir and is named exactly 'i18n.yaml'.
  2. Fix the bundle dir configuration/env var to the folder containing i18n.yaml.
  3. Correct file permissions on the file and its directory.
  4. Re-copy the i18n bundle from the source repository into your build/deploy artifact.

Example fix

// before (Dockerfile)
COPY --from=build /app/answer /usr/bin/answer
// after
COPY --from=build /app/answer /usr/bin/answer
COPY --from=build /app/i18n /app/i18n
ENV ANSWER_I18N_BUNDLE_DIR=/app/i18n
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(filepath.Join(bundleDir, "i18n.yaml")); err != nil {
  panic("i18n.yaml missing from bundle dir: " + bundleDir)
}

Try / catch

tr, err := translator.NewTranslator(cfg)
if err != nil {
  if strings.HasPrefix(err.Error(), "read i18n file failed:") {
    log.Fatalf("missing/invalid i18n.yaml: %v", err)
  }
  return err
}

Prevention

When it happens

Trigger: i18n.yaml missing from BundleDir, wrong BundleDir configured, or unreadable file (permissions/typo in filename such as I18N.yaml).

Common situations: Fresh deployment without bundled i18n files, custom builds that strip i18n.yaml, case-sensitive filesystems where the file was renamed (i18n.YAML), running from a working directory without the translations.

Related errors


AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05). Data as JSON: /api/errors/434513774e8639a4. Report an issue: GitHub.