languagetool-org/languagetool · error · RuntimeException
Not supported: " + fromLang + " -> " + toLang
Error message
Not supported: " + fromLang + " -> " + toLang
What it means
BeoLingusTranslator.translate only supports German->English and English->German lookups against its two in-memory maps. Any other language pair passed in fromLang/toLang throws a RuntimeException naming the unsupported direction.
Source
Thrown at languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/translation/BeoLingusTranslator.java:183
mergedList.add(item);
merging = true;
} else {
mergedList.add(item);
}
mergeListPos++;
}
return mergedList;
}
@Override
public List<TranslationEntry> translate(String term, String fromLang, String toLang) {
Map<String, List<TranslationEntry>> map;
if (fromLang.equals("de") && toLang.equals("en")) {
map = this.de2en;
} else if (fromLang.equals("en") && toLang.equals("de")) {
map = this.en2de;
} else {
throw new RuntimeException("Not supported: " + fromLang + " -> " + toLang);
}
List<TranslationEntry> entries = map.get(term.toLowerCase());
Set<TranslationEntry> entriesSet = new HashSet<>();
if (entries != null) {
entriesSet.addAll(entries);
}
List<TranslationEntry> translationsForBaseforms = getTranslationsForBaseforms(term, map);
for (TranslationEntry trans : translationsForBaseforms) {
if (entries != null) {
Optional<TranslationEntry> first = entries.stream().filter(k -> k.getL1().equals(trans.getL1())).findFirst();
if (first.isPresent() && first.get().getL1().equals(trans.getL1())) {
// skip duplicates
} else {
entriesSet.add(trans);
}
} else {
entriesSet.add(trans);
}View on GitHub (pinned to 2e990059ce)
Solutions
- Only call translate with fromLang/toLang equal to "de"->"en" or "en"->"de".
- Validate the language pair before calling and route other pairs to a different translation component.
- If another direction is required, extend the translator to populate and consult an additional map.
Example fix
// before
translator.translate(term, "fr", "en");
// after
if (fromLang.equals("de") && toLang.equals("en")) {
translator.translate(term, "de", "en");
} Defensive patterns
Strategy: validation
Validate before calling
Set<List<String>> supported = Set.of(List.of("de","en"), List.of("en","de"));
if (!supported.contains(List.of(fromLang, toLang))) {
throw new UnsupportedOperationException("Pair not supported: " + fromLang + "->" + toLang);
} Try / catch
try {
translator.translate(term, fromLang, toLang);
} catch (RuntimeException e) {
if (e.getMessage().startsWith("Not supported:")) { /* fall back to another translator */ }
} Prevention
- Only use BeoLingusTranslator for de<->en pairs
- Centralize language-pair routing before calling translate
- Check direction support before adding the translator to a pipeline
When it happens
Trigger: Calling translate(term, "fr", "en") or any language pair other than ("de","en") and ("en","de") on a BeoLingusTranslator instance.
Common situations: Reusing the translator in code that handles multiple language pairs; passing language codes in the wrong case or wrong variable; assuming the class supports the file's other translation directions (en2de is loaded but noted as not populated).
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- <regexp> rules currently cannot be used together with <antip
- Could not tag '" + term + "'
- Not implemented
- Format error in file ${path}, line: ${line}
- No IssueType found for name '" + name + "'. Valid values: "
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/12ec2c63e8c9da46.
Report an issue: GitHub.