Mintplex-Labs/anything-llm · warning

Tag ${tags[i]} was lost in translation

Error message

  Tag ${tags[i]} was lost in translation

What it means

Companion diagnostic printed right after the 'Missing Trans tags' summary: the code loops over every original tag captured by extractTransTags() and reports each one whose exact literal form (e.g. '</italic>') is not included in the translated text via String.includes(). It names precisely which markup tokens the LLM lost, so you know what to restore by hand in the generated locale file.

Source

Thrown at extras/translator/index.mjs:198

                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++) {
                    if (!translatedText.includes(placeholders[i])) {
                        console.warn(`  Placeholder ${placeholders[i]} was lost in translation`);
                    }

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Use the printed tag list to patch the named tags back into the generated locale entry (keep the tag order/parity of the source string — every opening tag needs its closing partner).
  2. Re-translate just the affected strings; per-string retries usually recover the token.
  3. If the same tag is lost repeatedly across languages, simplify that source string (fewer tags) or switch translation model.
  4. Sanity-check the fixed entry by diffing tag sets between source and translation before committing.

Example fix

// before: generated locale lost the tags reported by the warning
// source: "welcome": "Welcome <bold>back</bold>!"
"welcome": "Willkommen zurück!"

// after: restore the reported <bold>/</bold> tags manually
"welcome": "Willkommen <bold>zurück</bold>!"
Defensive patterns

Strategy: validation

Validate before calling

const transTagsOf = (s) => s.match(/<\/?[a-zA-Z][a-zA-Z0-9]*\s*\/?>/g) || [];

function reportLostTags(source, translated) {
  const present = new Set(transTagsOf(translated));
  return transTagsOf(source).filter(tag => !present.has(tag)); // exactly the per-tag list the warning prints
}

Prevention

When it happens

Trigger: Same translation pipeline as the summary warning — any individual tag whose literal string was dropped, translated, or mangled by the model appears here, one line per lost tag.

Common situations: Reviewing batch translation logs to decide which locale keys need manual repair; typically only a few strings lose tags, and this per-tag list maps directly onto the edits needed in the output JSON.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/f5e6750d5be7ef7c. Report an issue: GitHub.