{"record":{"id":"82ee7f4cfcbed011","repo":"Mintplex-Labs/anything-llm","slug":"placeholder-placeholders-i-was-lost-in-trans","errorCode":null,"errorMessage":"  Placeholder ${placeholders[i]} was lost in translation","messagePattern":"  Placeholder (.+?) was lost in translation","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extras/translator/index.mjs","lineNumber":215,"sourceCode":"                    if (!translatedText.includes(tags[i])) {\n                        console.warn(`  Tag ${tags[i]} was lost in translation`);\n                    }\n                }\n            }\n        }\n        \n        // Restore original placeholders\n        if (hasPlaceholders) {\n            translatedText = restorePlaceholders(translatedText, placeholders);\n            \n            // Validate all placeholders were preserved\n            const validation = validatePlaceholders(text, translatedText);\n            if (!validation.valid) {\n                console.warn(`Warning: Missing placeholders in translation: ${validation.missing.join(', ')}`);\n                // Attempt to fix by checking if tokens remain untranslated\n                for (let i = 0; i < placeholders.length; i++) {\n                    if (!translatedText.includes(placeholders[i])) {\n                        console.warn(`  Placeholder ${placeholders[i]} was lost in translation`);\n                    }\n                }\n            }\n        }\n        \n        return translatedText;\n    }\n\n    writeTranslations(langCode, translations) {\n        let langFilename = langCode.toLowerCase();\n        // Special cases\n        if(langCode === 'pt') langFilename = 'pt_BR';\n        if(langCode === 'zh-tw') langFilename = 'zh_TW';\n        if(langCode === 'vi') langFilename = 'vn';\n\n        fs.writeFileSync(\n            `../../frontend/src/locales/${langFilename}/common.js`,\n            `// Anything with \"null\" requires a translation. Contribute to translation via a PR!","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/extras/translator/index.mjs#L197-L233","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Re-translate just those keys — a targeted retry usually preserves the token.","If a raw __PLACEHOLDER_n__ token leaked into the output, replace it with the corresponding original placeholder by index.","Before committing, diff placeholder sets (source vs translation) for the touched keys to confirm parity."],"exampleFix":"// before: reported '{{count}} was lost in translation'\n// source: \"items_one\": \"You have {{count}} item\"\n\"items_one\": \"Du hast einen Artikel\"\n\n// after: placeholder restored verbatim\n\"items_one\": \"Du hast {{count}} Artikel\"","handlingStrategy":"validation","validationCode":"const placeholdersOf = (s) => s.match(/\\{\\{[^}]+\\}\\}/g) || [];\n\nfunction reportLostPlaceholders(source, translated) {\n  const present = new Set(placeholdersOf(translated));\n  return placeholdersOf(source).filter(p => !present.has(p)); // the exact {{vars}} named in the warning\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the per-placeholder warning lines to patch only the flagged keys: re-insert each {{var}} exactly as spelled in the source (same case, no inner spaces).","Run a locale-file linter in CI that fails when a translation's placeholder set diverges from its source key.","Never let generated locale files merge on green logs alone — placeholder loss is silent at runtime until interpolation renders wrong."],"tags":["i18n","translation","placeholders","interpolation","llm"],"backgroundTag":"i18n-placeholder-mismatch","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}