Mintplex-Labs/anything-llm · warning

Placeholder ${placeholders[i]} was lost in translation

Error message

  Placeholder ${placeholders[i]} was lost in translation

What it means

Per-placeholder companion warning printed inside the same validation loop: every {{variable}} captured from the source whose literal form is absent from the translated text is reported individually. It tells you exactly which interpolation variables will be broken if the generated locale file ships as-is, complementing the 'Missing placeholders' summary line.

Source

Thrown at extras/translator/index.mjs:215

                    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`);
                    }
                }
            }
        }
        
        return translatedText;
    }

    writeTranslations(langCode, translations) {
        let langFilename = langCode.toLowerCase();
        // Special cases
        if(langCode === 'pt') langFilename = 'pt_BR';
        if(langCode === 'zh-tw') langFilename = 'zh_TW';
        if(langCode === 'vi') langFilename = 'vn';

        fs.writeFileSync(
            `../../frontend/src/locales/${langFilename}/common.js`,
            `// Anything with "null" requires a translation. Contribute to translation via a PR!

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Edit the named keys in the generated locale file: re-insert each reported {{variable}} exactly as in the source (same name, same braces, no spaces).
  2. Re-translate just those keys — a targeted retry usually preserves the token.
  3. If a raw __PLACEHOLDER_n__ token leaked into the output, replace it with the corresponding original placeholder by index.
  4. Before committing, diff placeholder sets (source vs translation) for the touched keys to confirm parity.

Example fix

// before: reported '{{count}} was lost in translation'
// source: "items_one": "You have {{count}} item"
"items_one": "Du hast einen Artikel"

// after: placeholder restored verbatim
"items_one": "Du hast {{count}} Artikel"
Defensive patterns

Strategy: validation

Validate before calling

const placeholdersOf = (s) => s.match(/\{\{[^}]+\}\}/g) || [];

function reportLostPlaceholders(source, translated) {
  const present = new Set(placeholdersOf(translated));
  return placeholdersOf(source).filter(p => !present.has(p)); // the exact {{vars}} named in the warning
}

Prevention

When it happens

Trigger: Identical conditions to the placeholder summary warning — each individually lost/mangled {{var}} (via its __PLACEHOLDER_n__ token) produces one of these lines naming that variable.

Common situations: Auditing translator output logs before committing locale files; plural keys like 'itemCount': '{{count}} items' where the model drops or translates {{count}}; fixing only the flagged keys instead of re-translating the whole file.

Related errors


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