languagetool-org/languagetool · error · RuntimeException
Translation language (
Error message
Translation language (
What it means
When parsing false-friend XML, the handler requires that a rule's translation language differs from the pattern language when running in test mode. If a <translation lang="..."> names the same language as the rule's own language, it throws this RuntimeException — such a rule would compare a language with itself, which is meaningless for false friends.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/FalseFriendRuleHandler.java:106
}
correctExamples = new ArrayList<>();
incorrectExamples = new ArrayList<>();
} else if (qName.equals(PATTERN)) {
inPattern = true;
String languageStr = attrs.getValue("lang");
if (Languages.isLanguageSupported(languageStr)) {
language = Languages.getLanguageForShortCode(languageStr);
}
} else if (qName.equals(TOKEN)) {
setToken(attrs);
} else if (qName.equals(TRANSLATION)) {
inTranslation = true;
String languageStr = attrs.getValue("lang");
if (Languages.isLanguageSupported(languageStr)) {
Language tmpLang = Languages.getLanguageForShortCode(languageStr);
currentTranslationLanguage = tmpLang;
if (inTestMode && currentTranslationLanguage == language) {
throw new RuntimeException("Translation language (" + currentTranslationLanguage + ") must not be the same as pattern language (" + language + ") for rule " + id);
}
if (tmpLang.equalsConsiderVariantsIfSpecified(motherTongue)) {
translationLanguage = tmpLang;
}
}
} else if (qName.equals(EXAMPLE)) {
correctExample = new StringBuilder();
incorrectExample = new StringBuilder();
if (attrs.getValue(TYPE).equals("incorrect")) {
inIncorrectExample = true;
} else if (attrs.getValue(TYPE).equals("correct")) {
inCorrectExample = true;
} else if (attrs.getValue(TYPE).equals("triggers_error")) {
throw new RuntimeException("'triggers_error' is not supported for false friend XML");
}
} else if (qName.equals(MESSAGE)) {
inMessage = true;
message = new StringBuilder();View on GitHub (pinned to 2e990059ce)
Solutions
- Change the <translation lang="..."> value to a language different from the pattern language
- Remove the redundant translation element if it doesn't represent a real false-friend pair
- Check the false-friends.xml diff that introduced the duplicate language and correct it
Example fix
// before <rule id="FRIEND_EN" ...> <!-- pattern lang="en" --> <translation lang="en">tip</translation> // after <rule id="FRIEND_EN" ...> <!-- pattern lang="en" --> <translation lang="de">Tip</translation>
Defensive patterns
Strategy: validation
Validate before calling
if (translationLang.equals(patternLang)) {
throw new IllegalArgumentException("Translation lang must differ from pattern lang");
} Try / catch
try {
rules = loader.getRules(file, language, motherTongue);
} catch (RuntimeException e) {
if (e.getMessage().startsWith("Translation language (")) {
throw new IOException("Invalid false-friend XML: " + e.getMessage(), e);
}
throw e;
} Prevention
- Ensure each <translation lang> differs from the rule's pattern language
- Lint false-friends.xml in CI with the same test-mode parser
- Review diffs adding new false-friend pairs for copied lang codes
When it happens
Trigger: Parsing a false-friend XML file (e.g. src/main/resources/org/languagetool/rules/false-friends.xml) in test mode where a <translation> element's lang attribute equals the rule/pattern language, e.g. an 'en' pattern with an 'en' translation.
Common situations: Adding a new false-friend entry and accidentally duplicating the source language in a translation element; copying a translation block and forgetting to change its lang code.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- ApostropheTypeFilter: Index out of bounds in
- 'triggers_error' is not supported for false friend XML
- Rule group
- No rules are active. Please make sure your rule ids (<option
- List of language models is empty
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/20ffad898d804441.
Report an issue: GitHub.