{"record":{"id":"b3a1c5ecc82cb8b6","repo":"kataras/iris","slug":"catalog-empty-languages","errorCode":null,"errorMessage":"catalog: empty languages","messagePattern":"catalog: empty languages","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"i18n/internal/catalog.go","lineNumber":52,"sourceCode":"type Options struct {\n\t// Left delimiter for template messages.\n\tLeft string\n\t// Right delimeter for template messages.\n\tRight string\n\t// Enable strict mode.\n\tStrict bool\n\t// Optional functions for template messages per locale.\n\tFuncs func(context.Locale) template.FuncMap\n\t// Optional function to be called when no message was found.\n\tDefaultMessageFunc MessageFunc\n\t// Customize the overall behavior of the plurazation feature.\n\tPluralFormDecoder PluralFormDecoder\n}\n\n// NewCatalog returns a new Catalog based on the registered languages and the loader options.\nfunc NewCatalog(languages []language.Tag, opts Options) (*Catalog, error) { // ordered languages, the first should be the default one.\n\tif len(languages) == 0 {\n\t\treturn nil, fmt.Errorf(\"catalog: empty languages\")\n\t}\n\n\tif opts.Left == \"\" {\n\t\topts.Left = \"{{\"\n\t}\n\n\tif opts.Right == \"\" {\n\t\topts.Right = \"}}\"\n\t}\n\n\tif opts.PluralFormDecoder == nil {\n\t\topts.PluralFormDecoder = DefaultPluralFormDecoder\n\t}\n\n\tbuilder := catalog.NewBuilder(catalog.Fallback(languages[0]))\n\n\tlocales := make([]*Locale, 0, len(languages))\n\tfor idx, tag := range languages {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/i18n/internal/catalog.go#L34-L70","documentation":"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.","triggerScenarios":"Passing an empty languages slice to i18n.New / catalog.NewCatalog — e.g. deriving languages from directory scanning or config that matched no files.","commonSituations":"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.","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"],"exampleFix":"// before\ni, err := i18n.New(i18n.Glob(\"./locales/*.yml\")) // dir empty -> empty languages\n// after\nif _, err := os.Stat(\"./locales/en.yml\"); err != nil { log.Fatal(\"missing default locale\") }\ni, err := i18n.New(i18n.Glob(\"./locales/*.yml\"), \"en\", \"el\")","handlingStrategy":"validation","validationCode":"if len(languages) == 0 {\n    return errors.New(\"i18n: no languages detected; check locale directory\")\n}","typeGuard":null,"tryCatchPattern":"cat, err := i18n.New(loader, langs...)\nif err != nil && strings.Contains(err.Error(), \"empty languages\") {\n    log.Fatal(\"no translation files found; verify locale path and bundling\")\n}","preventionTips":["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"],"tags":["go","i18n","configuration","catalog"],"backgroundTag":"empty-languages-configuration","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}