{"record":{"id":"86be71797e50b910","repo":"kataras/iris","slug":"locales-not-found-in-map","errorCode":null,"errorMessage":"locales not found in map","messagePattern":"locales not found in map","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"i18n/loader.go","lineNumber":131,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, langIndex := range languageIndexes {\n\t\t\tif langIndex == -1 {\n\t\t\t\t// If loader has more languages than defined for use in New function,\n\t\t\t\t// e.g. when New(KV(m), \"en-US\") contains el-GR and en-US but only \"en-US\" passed.\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tkv := keyValuesMulti[langIndex]\n\t\t\terr := cat.Store(langIndex, kv)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\tif n := len(cat.Locales); n == 0 {\n\t\t\treturn nil, fmt.Errorf(\"locales not found in map\")\n\t\t} else if options.Strict && n < len(m.Languages) {\n\t\t\treturn nil, fmt.Errorf(\"locales expected to be %d but %d parsed\", len(m.Languages), n)\n\t\t}\n\n\t\treturn cat, nil\n\t}\n}\n\n// DefaultLoaderConfig represents the default loader configuration.\nvar DefaultLoaderConfig = LoaderConfig{\n\tLeft:               \"{{\",\n\tRight:              \"}}\",\n\tStrict:             false,\n\tDefaultMessageFunc: nil,\n\tPluralFormDecoder:  internal.DefaultPluralFormDecoder,\n\tFuncs:              nil,\n}\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/i18n/loader.go#L113-L149","documentation":"The KV loader (i18n.KV) builds a Catalog from a LangMap and requires at least one locale to be successfully stored. If cat.Locales is empty after storing, it returns \"locales not found in map\". This happens when none of the languages in the map matched the languages registered in the Matcher (New's language arguments).","triggerScenarios":"Calling iris.New(i18n.KV(langMap), \"en-US\") (or app.I18n.Load with KV) where parseLanguageName returns -1 for every language in the map — i.e. the map's language keys don't match any of the languages passed to New/I18n initialization.","commonSituations":"Language key mismatches: map has \"en\" but New registered \"en-US\" (or vice versa), misspelled tags, or using subtags/newLoaderConfig where only a subset of languages was declared.","solutions":["Ensure the languages passed to New/i18n initialization exactly match (or are parent tags of) the LangMap keys.","Normalize language tags: use the same form in both places (e.g. \"en-US\" vs \"en\").","Log/verify which languages the Matcher registered before loading.","Remove Strict=false assumptions — this error fires regardless of Strict when zero locales parse."],"exampleFix":"// before\napp := iris.New()\napp.I18n.Load(i18n.KV(i18n.LangMap{\"en-US\": {...}})) // no languages registered\n// after\napp.I18n.Load(i18n.KV(i18n.LangMap{\"en-US\": {...}}), \"en-US\")","handlingStrategy":"validation","validationCode":"// verify map keys match registered languages before loading\nfor lang := range langMap {\n    t := language.Make(lang)\n    if t.String() == \"und\" {\n        return fmt.Errorf(\"unparseable language tag in map: %q\", lang)\n    }\n    log.Printf(\"locale %s -> %s\", lang, t)\n}\nif len(langMap) == 0 {\n    return fmt.Errorf(\"langMap is empty\")\n}","typeGuard":null,"tryCatchPattern":"localizer, err := i18n.KV(langMap)(matcher)\nif err != nil && strings.Contains(err.Error(), \"locales not found in map\") {\n    return fmt.Errorf(\"no languages in map matched registered languages %v: %w\", registered, err)\n}","preventionTips":["Pass the exact same language tags to New that you use as map keys.","Keep one canonical spelling per locale (e.g. always \"en-US\").","Log matched/unmatched languages during load.","Add a startup assertion that at least one locale loaded."],"tags":["i18n","go","loader","locales"],"backgroundTag":"no-locales-loaded","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}