SubtitleEdit/subtitleedit · error · Exception

Dvd language {code} not found!

Error message

Dvd language {code} not found!

What it means

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.

Source

Thrown at src/libse/Common/DvdSubtitleLanguage.cs:232

        public DvdSubtitleLanguage(string code, string localName, string nativeName)
        {
            Code = code;
            LocalName = localName;
            NativeName = nativeName;
        }

        private DvdSubtitleLanguage(string description)
        {
            NativeName = description.Substring(3);
            var code = description.Remove(2);
            Code = code;
            if (Language.LanguageNames.TryGetValue(ConvertDvdToIso(code), out var localName))
            {
                LocalName = localName;
            }
            else
            {
                throw new Exception($"Dvd language {code} not found!");
            }
        }

        public override string ToString()
        {
            return LocalName;
        }

        public static DvdSubtitleLanguage English => CompliantLanguagesByCode["en"];

        public static IEnumerable<DvdSubtitleLanguage> CompliantLanguages => CompliantLanguagesByCode;

        private static LanguagesByCode CompliantLanguagesByCode
        {
            get
            {
                if (_compliantLanguagesByCode == null)
                {

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Ensure every 2-letter code in the descriptor list has an entry in Language.LanguageNames before adding it.
  2. Make ConvertDvdToIso return a stable fallback (the raw code) so the lookup never misses for known DVD-only codes.
  3. Change the constructor to set LocalName = NativeName when the dictionary lookup fails instead of throwing.
  4. Validate the descriptor against LanguageNames at test time to catch gaps before release.

Example fix

// before
if (Language.LanguageNames.TryGetValue(ConvertDvdToIso(code), out var localName))
    LocalName = localName;
else
    throw new Exception($"Dvd language {code} not found!");

// after
var iso = ConvertDvdToIso(code);
LocalName = Language.LanguageNames.TryGetValue(iso, out var localName) ? localName : NativeName;
Defensive patterns

Strategy: validation

Validate before calling

var iso = ConvertDvdToIso(code);
if (!Language.LanguageNames.ContainsKey(iso)) throw new ArgumentException($"Missing ISO mapping for DVD code {code}");

Type guard

static bool IsKnownDvdCode(string code) =>
    Language.LanguageNames.ContainsKey(ConvertDvdToIso(code));

Try / catch

try { var lang = new DvdSubtitleLanguage(desc); }
catch (Exception ex) when (ex.Message.Contains("Dvd language")) { /* skip or default */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/b1951fa94e75e6a8. Report an issue: GitHub.