{"record":{"id":"fde4bd3ab075ad3c","repo":"Humanizr/Humanizer","slug":"locale-parsedlocale-localecode-is-defined-more","errorCode":null,"errorMessage":"Locale '{parsedLocale.LocaleCode}' is defined more than once.","messagePattern":"Locale '(.+?)' is defined more than once\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs","lineNumber":97,"sourceCode":"\n        public static LocaleCatalogInput Create(ImmutableArray<LocaleDefinitionFile?> files)\n        {\n            var diagnostics = ImmutableArray.CreateBuilder<Diagnostic>();\n            var parsedLocales = new Dictionary<string, LocaleDefinition>(StringComparer.Ordinal);\n\n            foreach (var file in files)\n            {\n                if (file is null)\n                {\n                    continue;\n                }\n\n                try\n                {\n                    var parsedLocale = ParseLocaleDefinition(file.LocaleCode, file.FileText);\n                    if (parsedLocales.ContainsKey(parsedLocale.LocaleCode))\n                    {\n                        throw new InvalidOperationException($\"Locale '{parsedLocale.LocaleCode}' is defined more than once.\");\n                    }\n\n                    parsedLocales[parsedLocale.LocaleCode] = parsedLocale;\n                }\n                catch (Exception exception)\n                {\n                    diagnostics.Add(Diagnostic.Create(\n                        HumanizerSourceGenerator.Diagnostics.InvalidLocaleDefinition,\n                        Location.None,\n                        file.LocaleCode,\n                        exception.Message));\n                }\n            }\n\n            // Resolve inheritance once at the catalog boundary so every downstream generator sees a\n            // fully merged locale payload instead of reimplementing merge semantics independently.\n            // That keeps supported locale variants on the localized parent chain instead of\n            // allowing each generator to guess its own fallback behavior.","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs#L79-L115","documentation":"Thrown by LocaleCatalogInput.Create when two locale files resolve to the same LocaleCode (the file name without extension under src/Humanizer/Locales). Each locale code must be defined exactly once across the whole Locales tree. Surfaced as compiler diagnostic HSG003 (severity Error).","triggerScenarios":"Adding a new file whose name collides with an existing locale (e.g. a second fr.yml in a different subfolder, or a copy fr.yml.bak that is also picked up), or two files differing only by case on a case-insensitive filesystem.","commonSituations":"Copy-paste to start a new locale and forgetting to rename the file; backup files with .yml extension left in the tree; case-collision on macOS/Windows checkouts; merge bringing in a duplicate.","solutions":["Locate both files matching the locale code reported in the message and remove or rename one.","Ensure backup/scratch files do not use the .yml extension (the generator only loads .yml files under Locales).","On case-insensitive filesystems, verify the on-disk casing matches the intended code exactly once.","Rebuild to confirm the HSG003 diagnostic clears."],"exampleFix":"# before: two files both resolve to locale code 'fr'\n#   src/Humanizer/Locales/fr.yml\n#   src/Humanizer/Locales/wip/fr.yml\n# after: keep one\n#   src/Humanizer/Locales/fr.yml\n#   (delete src/Humanizer/Locales/wip/fr.yml or rename it to the intended new code)","handlingStrategy":"validation","validationCode":"# List locale codes derived from file names and flag duplicates.\nfind src/Humanizer/Locales -name '*.yml' -printf '%f\\n' | sed 's/\\.yml$//' | sort | uniq -d\n# Also catch stray .yml backups:\nfind src/Humanizer/Locales -name '*.yml*' -type f","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name each locale file exactly once with its BCP-47 code; never duplicate across subfolders.","Keep backups outside the Locales tree or with a non-.yml extension.","On case-insensitive filesystems, double-check casing matches the intended code."],"tags":["humanizer","source-generator","locale","yaml","localization","duplicate","filesystem"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}