languagetool-org/languagetool · error · IllegalArgumentException
You have to set the source language (as mother tongue) in bi
Error message
You have to set the source language (as mother tongue) in bitext mode
What it means
In bitext (bilingual) mode LanguageTool needs the source language to align the two texts; it is taken from the --mother-tongue option. If --bitext is given without --mother-tongue, main() throws this IllegalArgumentException before any checking starts.
Source
Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/Main.java:455
}
if (languageHint != null) {
String spellHint = "";
if (!prg.isSpellCheckingActive()) {
if (prg.lt.getLanguage().isVariant()) {
spellHint = " (no spell checking active)";
} else {
spellHint = " (no spell checking active, specify a language variant like 'en-GB' if available)";
}
}
System.err.println(languageHint + spellHint);
}
prg.setListUnknownWords(options.isListUnknown());
if (options.isProfile()) {
prg.setProfilingMode();
}
if (options.isBitext()) {
if (options.getMotherTongue() == null) {
throw new IllegalArgumentException("You have to set the source language (as mother tongue) in bitext mode");
}
File bitextRuleFile = options.getBitextRuleFile() != null ? new File(options.getBitextRuleFile()) : null;
prg.setBitextMode(options.getMotherTongue(), options.getDisabledRules(), options.getEnabledRules(), bitextRuleFile);
}
if (options.isRecursive()) {
prg.runRecursive(options.getFilename(), options.getEncoding(), options.isXmlFiltering(), options.getLevel());
} else {
if (options.isLineByLine()) {
prg.runOnFileLineByLine(options.getFilename(), options.getEncoding(), options.getLevel());
} else {
prg.runOnFile(options.getFilename(), options.getEncoding(), options.isXmlFiltering());
}
}
prg.cleanUp();
}
private static void printLanguages() {
List<String> languages = new ArrayList<>();View on GitHub (pinned to 2e990059ce)
Solutions
- Add --mother-tongue <sourceLanguageCode> alongside --bitext.
- Ensure the source language code is a supported Language (e.g. en-US, de-DE).
- If you do not actually want bitext checking, drop the --bitext flag.
Example fix
// before languagetool -l de-DE --bitext --bitextrules rules.xml pair.txt // after languagetool -l de-DE --mother-tongue en-US --bitext --bitextrules rules.xml pair.txt
Defensive patterns
Strategy: validation
Validate before calling
if (options.isBitext() && options.getMotherTongue() == null) {
throw new IllegalArgumentException("--mother-tongue is required with --bitext");
} Try / catch
try {
prg.setBitextMode(motherTongue, disabled, enabled, bitextRuleFile);
} catch (IllegalArgumentException e) {
printUsageAndExit("bitext mode requires --mother-tongue");
} Prevention
- Always pass --mother-tongue when using --bitext.
- Add a CLI preflight that checks required flag combinations.
- Document bitext requirements in wrapper scripts.
When it happens
Trigger: Running the CLI with --bitext (bitext rule file mode) but omitting --mother-tongue <lang>.
Common situations: New users assuming the target language (-l) suffices for bitext checking; scripts migrated from plain mode to bitext mode without adding the source-language flag.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- JSON output format is not implemented for Bitext
- Missing argument to <option> command line option.
- Parameter --config must be set and point to a property file
- Missing argument for '--logIpMatchingPattern' (e.g. any rand
- WrongParameterNumberException
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/3c73740fd3d29071.
Report an issue: GitHub.