Mintplex-Labs/anything-llm · warning
Warning: Missing Trans tags in translation: ${tagValidation.
Error message
Warning: Missing Trans tags in translation: ${tagValidation.missing.join(', ')} What it means
The extras/translator tool protects react-i18next <Trans> markup by rewriting tags like <bold>/</bold> into opaque __TAG_n__ tokens before sending text to the LLM, then restoring them afterwards. After restore, validateTransTags() regex-matches tag occurrences in source vs translated text; if any tag from the source is absent, this summary warning lists every missing tag. The output string is still returned — the locale entry just renders without that formatting.
Source
Thrown at extras/translator/index.mjs:195
model: Translator.modelTag,
messages: [{ role: 'user', content: prompt }],
temperature: 0.1,
stream: false,
}),
});
if(!response.ok) throw new Error(`Failed to translate: ${response.statusText}`);
const data = await response.json();
let translatedText = this.cleanOutputText(data.message.content);
// Restore Trans component tags first (order matters since tags may contain placeholders)
if (hasTags) {
translatedText = restoreTransTags(translatedText, tags);
// Validate all tags were preserved
const tagValidation = validateTransTags(text, translatedText);
if (!tagValidation.valid) {
console.warn(`Warning: Missing Trans tags in translation: ${tagValidation.missing.join(', ')}`);
for (let i = 0; i < tags.length; i++) {
if (!translatedText.includes(tags[i])) {
console.warn(` Tag ${tags[i]} was lost in translation`);
}
}
}
}
// Restore original placeholders
if (hasPlaceholders) {
translatedText = restorePlaceholders(translatedText, placeholders);
// Validate all placeholders were preserved
const validation = validatePlaceholders(text, translatedText);
if (!validation.valid) {
console.warn(`Warning: Missing placeholders in translation: ${validation.missing.join(', ')}`);
// Attempt to fix by checking if tokens remain untranslated
for (let i = 0; i < placeholders.length; i++) {View on GitHub (pinned to 3aec848f28)
Solutions
- Re-run translation for the affected keys — nondeterministic loss often disappears on a second pass.
- Use a stronger translation model than the default 4B one (or lower randomness) so token fidelity improves.
- Manually re-insert the reported tags into the generated locale file before committing (the warning names exactly which tags are missing).
- Reduce tag density per string in source strings when possible — fewer tokens, fewer chances to lose one.
Example fix
// before: single-shot translate, lost tags ship silently
const out = await translator.translate(text, lang);
// after: validate tags and retry, fall back to flagging
let out;
for (let attempt = 0; attempt < 3; attempt++) {
out = await translator.translate(text, lang);
const srcTags = text.match(/<\/?[a-zA-Z][a-zA-Z0-9]*\s*\/?>/g) || [];
const ok = srcTags.every(t => out.includes(t));
if (ok) break;
if (attempt === 2) console.error(`tags still lost for key, manual fix needed`);
} Defensive patterns
Strategy: retry
Validate before calling
const transTagsOf = (s) => s.match(/<\/?[a-zA-Z][a-zA-Z0-9]*\s*\/?>/g) || []; const missingTransTags = (source, translated) => transTagsOf(source).filter(t => !transTagsOf(translated).includes(t)); const ok = missingTransTags(sourceText, translatedText).length === 0;
Try / catch
for (let attempt = 0; attempt < 3; attempt++) {
const out = await translator.translate(text, lang);
if (missingTransTags(text, out).length === 0) return out; // tags survived
}
throw new Error(`Translation kept losing Trans tags for: ${text}`); // route to manual fix Prevention
- Run translations through a validation gate comparing tag sets (and ordering parity) before writing locale files to disk.
- Use a model strong enough to copy opaque tokens verbatim; tiny models are the main cause of token loss.
- Keep tag counts per string low and avoid nesting <Trans> markup more than two levels deep.
When it happens
Trigger: Batch-translating locale files when the model deletes a __TAG_n__ token, translates it ("__ETIKETT_0__"), merges two tokens, or emits real markup like <bold> instead of the token — restore then can't reproduce the original tag and validateTransTags flags it. Strings with many/nested tags raise the odds.
Common situations: Running the translator on frontend locale JSON with a small local model (default translategemma:4b), long rich-text strings with several Trans tags, target languages with heavy reordering, or temperature/generation settings that make the model 'helpfully' rewrite tokens. The generated locale then drops bold/italic/link rendering for those keys.
Related errors
- Tag ${tags[i]} was lost in translation
- Warning: Missing placeholders in translation: ${validation.m
- Placeholder ${placeholders[i]} was lost in translation
- Unknown provider: ${config.provider}. Please use a valid pro
- An error occurred while downloading the model
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/c40350f8d721dc98.
Report an issue: GitHub.