shadow1ng/fscan · critical
failed to load en.yaml: %v
Error message
failed to load en.yaml: %v
What it means
Same init-time loading as zh.yaml but for locales/en.yaml, the fallback English translation file. A missing or malformed en.yaml makes the i18n bundle incomplete and the package panics deliberately at startup rather than serving broken translations.
Source
Thrown at common/i18n/i18n.go:41
)
var (
bundle *i18n.Bundle
localizer *i18n.Localizer
lang = DefaultLanguage
mu sync.RWMutex
)
func init() {
bundle = i18n.NewBundle(language.Chinese)
bundle.RegisterUnmarshalFunc("yaml", yaml.Unmarshal)
// 从embed加载翻译文件
if _, err := bundle.LoadMessageFileFS(localeFS, "locales/zh.yaml"); err != nil {
panic(fmt.Sprintf("failed to load zh.yaml: %v", err))
}
if _, err := bundle.LoadMessageFileFS(localeFS, "locales/en.yaml"); err != nil {
panic(fmt.Sprintf("failed to load en.yaml: %v", err))
}
localizer = i18n.NewLocalizer(bundle, lang, FallbackLanguage)
}
// SetLanguage 设置当前语言
func SetLanguage(l string) {
mu.Lock()
defer mu.Unlock()
lang = l
localizer = i18n.NewLocalizer(bundle, lang, FallbackLanguage)
}
// GetLanguage returns the currently configured language.
func GetLanguage() string {
mu.RLock()
defer mu.RUnlock()
return langView on GitHub (pinned to 95cc12e753)
Solutions
- Confirm common/i18n/locales/en.yaml exists and is covered by the //go:embed pattern
- Fix any YAML syntax errors in en.yaml
- Rebuild so the embedded FS reflects the on-disk file
Example fix
// before locales: - en.yaml missing // after // common/i18n/locales/en.yaml restored: // hello: // other: "Hello"
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := localeFS.ReadFile("locales/en.yaml"); err != nil {
// en.yaml missing or embed pattern mismatch; fix before build
} Try / catch
// init-time panic: cannot be caught; catch via CI test
test: func TestLocalesEmbedded(t *testing.T) {
if _, err := localeFS.ReadFile("locales/en.yaml"); err != nil {
t.Fatalf("en.yaml missing from embed: %v", err)
}
} Prevention
- Lint all YAML in locales/ in CI
- Never rename locale files without updating the embed directive
- Add a test that NewLocalizer succeeds with both languages
When it happens
Trigger: locales/en.yaml not embedded (missing file, embed directive mismatch), or en.yaml failing yaml.Unmarshal due to syntax errors.
Common situations: Hand-edited en.yaml with invalid YAML, file renamed during refactoring, or a merge that dropped the file while keeping the embed directive.
Related errors
- failed to load zh.yaml: %v
- local_pe_not_specified
- local_pe_not_found
- webscan_poc_convert_failed
- webscan_poc_file_read_failed
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/2e0d32a7b11e9dd0.
Report an issue: GitHub.