Add, change, or review user-facing text in the Langflow frontend using the i18n system (i18next / react-i18next). Use whenever a change adds or edits UI strings
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-frontend-i18n-998cefe1c957 ,按照其中的说明把「frontend-i18n」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
The Langflow frontend is internationalized with i18next + react-i18next. Locales live in src/frontend/src/locales/ — currently en, de, es, fr, ja, pt, zh-Hans. A hardcoded user-facing string, or a key missing from one locale, ships broken UI for part of the user base.
t(...) — never hardcoded JSX text for labels, buttons, tooltips, modals, toasts, errors, placeholders, aria-labels, or empty states.en.json, de.json, es.json, fr.json, ja.json, pt.json, zh-Hans.json). fallbackLng: "en" means a missing key silently shows English — it won't crash, which is exactly why reviews must catch it.src/frontend/src/i18n.ts — a custom i18next instance. en is bundled statically; other languages are lazy-loaded by loadLanguage() via dynamic import. Language preference comes from localStorage.getItem("languagePreference"), normalized (e.g. zh-CN → zh-Hans, unknown → en).deleteModal.title, errors.fileTooLarge, crash.restartButton. Follow the existing namespace of the area you're touching; create a new prefix only for a genuinely new surface.{{variable}} in the string and an options object in the call.import { useTranslation } from "react-i18next";
const { t } = useTranslation();
<span>{t("deleteModal.title")}</span>
<p>{t("errors.fileTooLarge", { maxSizeMB: "10MB" })}</p>
In locales/en.json (and every other locale file):
"errors.fileTooLarge": "The file size is too large. Please select a file smaller than {{maxSizeMB}}."
For the non-English locales, write a real translation when confident; if not, add the key with the English value and flag it in the PR — a present-but-untranslated key is visible and searchable, a missing key is invisible.
t("a") + name + t("b")) — word order differs across languages. Use one key with interpolation: t("greeting", { name }).t() calls (see how crash.descriptionBefore / crash.githubIssues / crash.descriptionAfter split around a link)._one / _other suffixes), not count === 1 ? ... : ....Intl.* using the active locale, never hardcoded formats.placeholder, title, aria-label, toast/error text).src/frontend/src/locales/*.json).Quick check for a key across locales:
for f in src/frontend/src/locales/*.json; do grep -L '"my.new.key"' "$f"; done
(prints the locale files where the key is missing — should print nothing)