{"record":{"id":"20ffad898d804441","repo":"languagetool-org/languagetool","slug":"translation-language","errorCode":null,"errorMessage":"Translation language (","messagePattern":"Translation language \\(","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/patterns/FalseFriendRuleHandler.java","lineNumber":106,"sourceCode":"      }\n      correctExamples = new ArrayList<>();\n      incorrectExamples = new ArrayList<>();\n    } else if (qName.equals(PATTERN)) {\n      inPattern = true;\n      String languageStr = attrs.getValue(\"lang\");\n      if (Languages.isLanguageSupported(languageStr)) {\n        language = Languages.getLanguageForShortCode(languageStr);\n      }\n    } else if (qName.equals(TOKEN)) {\n      setToken(attrs);\n    } else if (qName.equals(TRANSLATION)) {\n      inTranslation = true;\n      String languageStr = attrs.getValue(\"lang\");\n      if (Languages.isLanguageSupported(languageStr)) {\n        Language tmpLang = Languages.getLanguageForShortCode(languageStr);\n        currentTranslationLanguage = tmpLang;\n        if (inTestMode && currentTranslationLanguage == language) {\n          throw new RuntimeException(\"Translation language (\" + currentTranslationLanguage + \") must not be the same as pattern language (\" + language + \") for rule \" + id);\n        }\n        if (tmpLang.equalsConsiderVariantsIfSpecified(motherTongue)) {\n          translationLanguage = tmpLang;\n        }\n      }\n    } else if (qName.equals(EXAMPLE)) {\n      correctExample = new StringBuilder();\n      incorrectExample = new StringBuilder();\n      if (attrs.getValue(TYPE).equals(\"incorrect\")) {\n        inIncorrectExample = true;\n      } else if (attrs.getValue(TYPE).equals(\"correct\")) {\n        inCorrectExample = true;\n      } else if (attrs.getValue(TYPE).equals(\"triggers_error\")) {\n        throw new RuntimeException(\"'triggers_error' is not supported for false friend XML\");\n      }\n    } else if (qName.equals(MESSAGE)) {\n      inMessage = true;\n      message = new StringBuilder();","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/patterns/FalseFriendRuleHandler.java#L88-L124","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n<rule id=\"FRIEND_EN\" ...> <!-- pattern lang=\"en\" -->\n  <translation lang=\"en\">tip</translation>\n// after\n<rule id=\"FRIEND_EN\" ...> <!-- pattern lang=\"en\" -->\n  <translation lang=\"de\">Tip</translation>","handlingStrategy":"validation","validationCode":"if (translationLang.equals(patternLang)) {\n  throw new IllegalArgumentException(\"Translation lang must differ from pattern lang\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  rules = loader.getRules(file, language, motherTongue);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Translation language (\")) {\n    throw new IOException(\"Invalid false-friend XML: \" + e.getMessage(), e);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["false-friend","rule-xml","configuration","language-parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}