{"record":{"id":"ea19f9896c53f341","repo":"Humanizr/Humanizer","slug":"locale-localecode-is-not-defined","errorCode":null,"errorMessage":"Locale '{localeCode}' is not defined.","messagePattern":"Locale '(.+?)' is not defined\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs","lineNumber":452,"sourceCode":"        static LocaleDefinition ParseLocaleDefinition(string localeCode, string fileText)\n        {\n            var document = CanonicalLocaleAuthoring.Parse(localeCode, fileText);\n            return CanonicalLocaleAuthoring.ToLocaleDefinition(document);\n        }\n\n        static ResolvedLocaleDefinition ResolveLocale(\n            string localeCode,\n            Dictionary<string, LocaleDefinition> parsedLocales,\n            HashSet<string> resolving,\n            ImmutableArray<ResolvedLocaleDefinition>.Builder cache,\n            ImmutableArray<Diagnostic>.Builder diagnostics)\n        {\n            if (cache.FirstOrDefault(cached => cached.LocaleCode == localeCode) is { } cached)\n                return cached;\n\n            if (!parsedLocales.TryGetValue(localeCode, out var locale))\n            {\n                throw new InvalidOperationException($\"Locale '{localeCode}' is not defined.\");\n            }\n\n            if (!resolving.Add(localeCode))\n            {\n                throw new InvalidOperationException($\"Locale inheritance cycle detected at '{localeCode}'.\");\n            }\n\n            ResolvedLocaleDefinition inherited;\n            if (string.IsNullOrWhiteSpace(locale.Inherits))\n            {\n                inherited = ResolvedLocaleDefinition.Empty(localeCode);\n            }\n            else\n            {\n                var inheritedLocale = locale.Inherits!;\n                if (!parsedLocales.ContainsKey(inheritedLocale))\n                {\n                    diagnostics.Add(Diagnostic.Create(","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs#L434-L470","documentation":"Thrown by ResolveLocale when a locale is referenced (typically via an 'inherits'/'variantOf' parent) but no locale file defines that code. Inheritance targets must exist in the catalog. Surfaced as compiler diagnostic HSG003 (severity Error).","triggerScenarios":"A locale file sets inherits: <parent> (or variantOf) to a code that has no corresponding file, e.g. inherits: fr-FR when only fr.yml exists, or a typo like inherits: en-US.","commonSituations":"Author renames a parent locale without updating children; typo in the inherits value; referencing a not-yet-added locale; case mismatch between the inherits value and the file name.","solutions":["Verify the parent code in the message matches an existing file name (without extension) under src/Humanizer/Locales.","Correct the inherits/variantOf value to the real parent code, or add the missing parent file.","Check casing: locale codes are compared ordinally, so fr-FR does not match fr-fr.","Rebuild to confirm the HSG003 diagnostic clears."],"exampleFix":"# before (file src/Humanizer/Locales/fr-FR.yml)\ninherits: fr-CA\n# after (no fr-CA.yml exists; inherit from fr instead)\ninherits: fr","handlingStrategy":"validation","validationCode":"# Collect every inherits/variantOf target and confirm a matching file exists.\ncodes=$(find src/Humanizer/Locales -name '*.yml' -printf '%f\\n' | sed 's/\\.yml$//' | sort -u)\ngrep -rhoE '^(inherits|variantOf):\\s*.*' src/Humanizer/Locales | awk '{print $2}' | sort -u | while read parent; do\n  echo \"$codes\" | grep -qxF \"$parent\" || echo \"MISSING PARENT: $parent\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When renaming or removing a locale, grep for inherits/variantOf referencing it and update children.","Match the parent code's casing exactly (ordinal comparison).","Add the parent file before pointing children at it."],"tags":["humanizer","source-generator","locale","yaml","localization","inheritance","variant-of"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}