{"record":{"id":"b1951fa94e75e6a8","repo":"SubtitleEdit/subtitleedit","slug":"dvd-language-code-not-found","errorCode":null,"errorMessage":"Dvd language {code} not found!","messagePattern":"Dvd language (.+?) not found!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/libse/Common/DvdSubtitleLanguage.cs","lineNumber":232,"sourceCode":"        public DvdSubtitleLanguage(string code, string localName, string nativeName)\n        {\n            Code = code;\n            LocalName = localName;\n            NativeName = nativeName;\n        }\n\n        private DvdSubtitleLanguage(string description)\n        {\n            NativeName = description.Substring(3);\n            var code = description.Remove(2);\n            Code = code;\n            if (Language.LanguageNames.TryGetValue(ConvertDvdToIso(code), out var localName))\n            {\n                LocalName = localName;\n            }\n            else\n            {\n                throw new Exception($\"Dvd language {code} not found!\");\n            }\n        }\n\n        public override string ToString()\n        {\n            return LocalName;\n        }\n\n        public static DvdSubtitleLanguage English => CompliantLanguagesByCode[\"en\"];\n\n        public static IEnumerable<DvdSubtitleLanguage> CompliantLanguages => CompliantLanguagesByCode;\n\n        private static LanguagesByCode CompliantLanguagesByCode\n        {\n            get\n            {\n                if (_compliantLanguagesByCode == null)\n                {","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/Common/DvdSubtitleLanguage.cs#L214-L250","documentation":"DvdSubtitleLanguage's private constructor splits a 'xx Name' descriptor into a 2-letter DVD code and a name, converts the code via ConvertDvdToIso, and looks it up in Language.LanguageNames. If the ISO code is absent from the dictionary the language cannot be localized and the constructor throws. This typically fires during static initialization of the CompliantLanguages table for any DVD language not present in the ISO map.","triggerScenarios":"Adding a new DVD language descriptor whose 2-letter code has no ISO 639-1 equivalent (e.g. 'bh' Bihari, 'ji' Yiddish-legacy, vendor-private codes); running with a LanguageNames dictionary that has been pruned or a culture resource missing entries.","commonSituations":"Updating the embedded DVD language list to a new region set; localized build where the LanguageNames resource for a specific code was dropped; custom/in-house DVD authoring with non-standard language codes.","solutions":["Ensure every 2-letter code in the descriptor list has an entry in Language.LanguageNames before adding it.","Make ConvertDvdToIso return a stable fallback (the raw code) so the lookup never misses for known DVD-only codes.","Change the constructor to set LocalName = NativeName when the dictionary lookup fails instead of throwing.","Validate the descriptor against LanguageNames at test time to catch gaps before release."],"exampleFix":"// before\nif (Language.LanguageNames.TryGetValue(ConvertDvdToIso(code), out var localName))\n    LocalName = localName;\nelse\n    throw new Exception($\"Dvd language {code} not found!\");\n\n// after\nvar iso = ConvertDvdToIso(code);\nLocalName = Language.LanguageNames.TryGetValue(iso, out var localName) ? localName : NativeName;","handlingStrategy":"validation","validationCode":"var iso = ConvertDvdToIso(code);\nif (!Language.LanguageNames.ContainsKey(iso)) throw new ArgumentException($\"Missing ISO mapping for DVD code {code}\");","typeGuard":"static bool IsKnownDvdCode(string code) =>\n    Language.LanguageNames.ContainsKey(ConvertDvdToIso(code));","tryCatchPattern":"try { var lang = new DvdSubtitleLanguage(desc); }\ncatch (Exception ex) when (ex.Message.Contains(\"Dvd language\")) { /* skip or default */ }","preventionTips":["Cross-check every DVD descriptor code against LanguageNames before adding it.","Provide fallback to NativeName when ISO lookup fails."],"tags":["dvd","language","localization","subtitle","config"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}