kataras/iris · error
locales not found in %s
Error message
locales not found in %s
What it means
The file-based loader (load, used by i18n.Glob/FS/Assets) parses locale files matched by assetNames and stores them per language. If after loading all files cat.Locales is empty, it returns "locales not found in <file1, file2, ...>". This means none of the asset files matched a registered language or none produced a stored locale.
Source
Thrown at i18n/loader.go:205
b, err := asset(fileName)
if err != nil {
return nil, err
}
if err = unmarshal(b, &keyValues); err != nil {
return nil, err
}
}
err = cat.Store(langIndex, keyValues)
if err != nil {
return nil, err
}
}
if n := len(cat.Locales); n == 0 {
return nil, fmt.Errorf("locales not found in %s", strings.Join(assetNames, ", "))
} else if options.Strict && n < len(m.Languages) {
return nil, fmt.Errorf("locales expected to be %d but %d parsed", len(m.Languages), n)
}
return cat, nil
}
}
func unmarshalINI(data []byte, v any) error {
f, err := ini.Load(data)
if err != nil {
return err
}
m := *v.(*map[string]any)
// Includes the ini.DefaultSection which has the root keys too.
// We don't have to iterate to each section to find the subsection,View on GitHub (pinned to 7bedaf55a0)
Solutions
- Check the listed asset names and rename files so they contain a registered language tag (e.g. locales/en-US.yml).
- Verify the Glob/FS pattern actually matches the files (print the matched names).
- Ensure the languages passed to New/i18n match the file language tags.
- Confirm embedded FS (go:embed) paths are relative to the embed root as expected.
Example fix
// before (unrecognized names) locales/locale-en-US.yaml // after locales/en-US.yaml
Defensive patterns
Strategy: validation
Validate before calling
// verify files match expected naming before load
matches, _ := filepath.Glob("./locales/*.yaml")
if len(matches) == 0 {
return fmt.Errorf("no locale files found in ./locales")
}
for _, f := range matches {
base := filepath.Base(f)
if !strings.Contains(base, "en") {
log.Printf("warning: %s does not encode a language tag", base)
}
} Try / catch
localizer, err := i18n.Glob("./locales/*/*.yaml")(matcher)
if err != nil && strings.Contains(err.Error(), "locales not found in") {
return fmt.Errorf("no locale files matched registered languages: %w", err)
} Prevention
- Name files with the language tag: en-US.yaml, el-GR.ini.
- Verify Glob/embed patterns match the actual directory layout.
- Keep file language tags in sync with languages registered in New.
- Log matched asset names during load to catch naming drift.
When it happens
Trigger: Calling i18n.Glob("./locales/*/*.yaml") (or FS/Assets) where ParseLanguageFiles found no files matching the registered languages' tags — filenames lack language names, wrong directory layout, or registered languages don't appear in any filename.
Common situations: Naming files locale-en.yml instead of en.yml (pattern the parser doesn't expect), files in a layout Glob doesn't match, embedded FS paths differing from local paths, or New registered with languages absent from the folder.
Related errors
- locales not found in map
- locales expected to be %d but %d parsed
- nil loader
- catalog: empty languages
- expected language index to be lower or equal than %d but got
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/d1cafe6a59188d6b.
Report an issue: GitHub.