{"record":{"id":"434513774e8639a4","repo":"apache/answer","slug":"read-i18n-file-failed-s","errorCode":null,"errorMessage":"read i18n file failed: %s","messagePattern":"read i18n file failed: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/base/translator/provider.go","lineNumber":113,"sourceCode":"\n\t\tcontent, err := yaml.Marshal(translation)\n\t\tif err != nil {\n\t\t\tlog.Debugf(\"marshal translation content failed: %s %s\", file.Name(), err)\n\t\t\tcontinue\n\t\t}\n\n\t\t// add translator use backend translation\n\t\tif err = myTran.AddTranslator(content, file.Name()); err != nil {\n\t\t\tlog.Debugf(\"add translator failed: %s %s\", file.Name(), err)\n\t\t\treportTranslatorFormatError(file.Name(), buf)\n\t\t\tcontinue\n\t\t}\n\t}\n\tGlobalTrans = myTran.GlobalTrans\n\n\ti18nFile, err := os.ReadFile(filepath.Join(c.BundleDir, \"i18n.yaml\"))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read i18n file failed: %s\", err)\n\t}\n\n\ts := struct {\n\t\tLangOption []*LangOption `yaml:\"language_options\"`\n\t}{}\n\terr = yaml.Unmarshal(i18nFile, &s)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"i18n file parsing failed: %s\", err)\n\t}\n\tLanguageOptions = s.LangOption\n\tfor _, option := range LanguageOptions {\n\t\toption.Label = fmt.Sprintf(\"%s (%d%%)\", option.Label, option.Progress)\n\t}\n\treturn GlobalTrans, err\n}\n\n// CheckLanguageIsValid check user input language is valid\nfunc CheckLanguageIsValid(lang string) bool {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/base/translator/provider.go#L95-L131","documentation":"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.","triggerScenarios":"i18n.yaml missing from BundleDir, wrong BundleDir configured, or unreadable file (permissions/typo in filename such as I18N.yaml).","commonSituations":"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.","solutions":["Ensure i18n.yaml exists at the configured BundleDir and is named exactly 'i18n.yaml'.","Fix the bundle dir configuration/env var to the folder containing i18n.yaml.","Correct file permissions on the file and its directory.","Re-copy the i18n bundle from the source repository into your build/deploy artifact."],"exampleFix":"// before (Dockerfile)\nCOPY --from=build /app/answer /usr/bin/answer\n// after\nCOPY --from=build /app/answer /usr/bin/answer\nCOPY --from=build /app/i18n /app/i18n\nENV ANSWER_I18N_BUNDLE_DIR=/app/i18n","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(bundleDir, \"i18n.yaml\")); err != nil {\n  panic(\"i18n.yaml missing from bundle dir: \" + bundleDir)\n}","typeGuard":null,"tryCatchPattern":"tr, err := translator.NewTranslator(cfg)\nif err != nil {\n  if strings.HasPrefix(err.Error(), \"read i18n file failed:\") {\n    log.Fatalf(\"missing/invalid i18n.yaml: %v\", err)\n  }\n  return err\n}","preventionTips":["Always ship i18n.yaml with the deployment artifact","Case-check filenames (exact lowercase i18n.yaml) for Linux filesystems","Add a startup smoke test that opens i18n.yaml","Document the bundle dir env var for operators"],"tags":["i18n","file-io","go","configuration"],"backgroundTag":"i18n-bundle-missing","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}