kataras/iris · error
catalog: empty languages
Error message
catalog: empty languages
What it means
catalog.NewCatalog builds a Catalog from an ordered slice of golang.org/x/text language.Tag values; the first becomes the default. An empty slice means there is no default language, so construction is rejected with this error.
Source
Thrown at i18n/internal/catalog.go:52
type Options struct {
// Left delimiter for template messages.
Left string
// Right delimeter for template messages.
Right string
// Enable strict mode.
Strict bool
// Optional functions for template messages per locale.
Funcs func(context.Locale) template.FuncMap
// Optional function to be called when no message was found.
DefaultMessageFunc MessageFunc
// Customize the overall behavior of the plurazation feature.
PluralFormDecoder PluralFormDecoder
}
// NewCatalog returns a new Catalog based on the registered languages and the loader options.
func NewCatalog(languages []language.Tag, opts Options) (*Catalog, error) { // ordered languages, the first should be the default one.
if len(languages) == 0 {
return nil, fmt.Errorf("catalog: empty languages")
}
if opts.Left == "" {
opts.Left = "{{"
}
if opts.Right == "" {
opts.Right = "}}"
}
if opts.PluralFormDecoder == nil {
opts.PluralFormDecoder = DefaultPluralFormDecoder
}
builder := catalog.NewBuilder(catalog.Fallback(languages[0]))
locales := make([]*Locale, 0, len(languages))
for idx, tag := range languages {View on GitHub (pinned to 7bedaf55a0)
Solutions
- Pass at least one language tag, with the default first, to i18n.New
- Fix the glob/path or directory scan so translation files are actually discovered
- Ship locale files with the deployment (embed them or copy into the container)
- Log the detected languages before constructing the catalog to catch empty detection early
Example fix
// before
i, err := i18n.New(i18n.Glob("./locales/*.yml")) // dir empty -> empty languages
// after
if _, err := os.Stat("./locales/en.yml"); err != nil { log.Fatal("missing default locale") }
i, err := i18n.New(i18n.Glob("./locales/*.yml"), "en", "el") Defensive patterns
Strategy: validation
Validate before calling
if len(languages) == 0 {
return errors.New("i18n: no languages detected; check locale directory")
} Try / catch
cat, err := i18n.New(loader, langs...)
if err != nil && strings.Contains(err.Error(), "empty languages") {
log.Fatal("no translation files found; verify locale path and bundling")
} Prevention
- Always pass the default language explicitly as the first argument
- Verify locale files are embedded/copied into the deployment artifact
- Log the resolved language list at startup
- Add a CI check that the locales directory is non-empty
When it happens
Trigger: Passing an empty languages slice to i18n.New / catalog.NewCatalog — e.g. deriving languages from directory scanning or config that matched no files.
Common situations: Translation directory empty or wrong path so language detection yields zero languages; config file missing the languages key; glob pattern with no matches; environments where locales were not bundled in the container image.
Related errors
- nil loader
- expected language index to be lower or equal than %d but got
- auth: configuration: %s access token is missing from the con
- %w: example: %s
- parse yaml: %w
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/b3a1c5ecc82cb8b6.
Report an issue: GitHub.