It does work for ISO639 language codes like "de" or "fr" but apparently does not take account of codes with variant tags like "de-1901" or "de-1996" according to RFC 1766 and RFC 5646. The codes "de-1901" (German, old spelling) and "de-1996" (German, new spelling) are ok (see
here; they are mentioned in RFC 5646, too).
Now, it happens that a text in the main part complies with new spelling, but contains citations using the old spelling. For both spelling variants dictionaries are installed in Calibre (new spelling as "dic-0SKY2G" and old spelling as "dic-1MYkc4") and there is a mapping
"preferred_dictionaries": {
"deu-DE": "dic-0SKY2G"
}
in prefs.json. What would be needed is a way to let the code "de-1996" map to "dic-0SKY2G" and "de-1901" map to "dic-1MYkc4".
@Kovid: I do not see how to follow your suggestion. Should I install a dictionary I would not use (e.g. Khmer) and copy the files from the German variant to the corresponding directory under ~/config/calibre/dictionaries? That would be an ugly hack.
In general, a situation as described above is IMHO not exotic but quite common. For instance, a scientific text would have the main part in American English but may contain lengthy verbatim citations in British English. So both language variants would be needed simultaneously.