Clean up editor i18n translations and add CI validation
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 43/100
- Issue 类型
- 重构
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- javascript, json, typescript
调研方向
Start with the translation modules under packages/editor/src/i18n/, then inspect GptDialog.tsx, useGpt.tsx, and the hints/math-hint consumers before changing keys. Read packages/editor/scripts/lint-i18n.js, scripts/lint-i18n.js, and packages/editor/src/i18n/__tests__/lint.test.ts to understand the lint and test structure; update the contribution guidelines for the naming convention. Done means EN/RU keys align, deprecated imports remain compatible, renamed keys have no dangling consumers, lint fixtures cover every rule, and pnpm lint:i18n, pnpm lint, and pnpm test pass.
由索引模型根据 Issue 内容生成。
描述
-
The editor's translation files (
packages/editor/src/i18n/) have accumulated a number of inconsistencies over time. The same UI labels are translated differently across modules, some EN/RU pairs carry different meanings, there are English copy mistakes, two keysets are exact duplicates, and there is no enforced key naming convention. -
Also nothing prevents new issues from being introduced. We want to do a focused cleanup pass and add a lightweight lint step to CI so the baseline stays clean going forward.
Scope:
- Fix translation inconsistencies where the same concept has different translations in different modules (e.g. Cancel, Preview, Try again)
- Fix semantic mismatches where EN and RU do not mean the same thing (e.g.
yfm-notewarning label,formsimage name field) - Fix English copy issues: typo in
forms, plural inmenubar, awkward phrasing ingpt/errors, locale-specific punctuation inbundle - Consolidate two identical keysets (
hints/andmath-hint/) - Fix one concrete naming inconsistency in
menubar(single vs double underscore separator); document the convention in a comment or CONTRIBUTING note (repo-wide rename is out of scope) - Add
scripts/lint-i18n.mjswired into the existing lint pipeline; checks: key parity between en/ru per module, no empty values, no obviously untranslated strings
Implementation Steps
Step 1 — Fix translation inconsistencies (same concept, different translation)
| Location | Key | Problem | Fix |
|---|---|---|---|
forms/ru.json, gpt/extension/ru.json |
common_action_cancel, confirm-cancel |
"Отменить" (verb) — should match common which uses "Отмена" (noun) |
Change to "Отмена" |
yfm-layout/ru.json |
cell.preview |
"Превью" — everywhere else Preview → "Предпросмотр" | Change to "Предпросмотр" |
gpt/dialog/en.json |
refetch and try-again |
Both have value "Try again" in EN, but different RU translations ("Попробовать ещё" vs "Иначе"). Before fixing: read GptDialog.tsx and useGpt.tsx to understand what each button actually does. If refetch is dead code, remove the key. If buttons have different behavior, fix the RU to match EN semantics; do not change try-again EN value based solely on the differing RU translation. |
Investigate first, then either remove dead key or align RU |
Step 2 — Fix semantic mismatches (EN and RU mean different things)
| Location | Key | EN | RU | Fix |
|---|---|---|---|---|
yfm-note/ |
warning |
"Warning" | "Важно" (Important) | ⚠️ Needs product decision — "Warning" and "Important" carry different meaning; do not change without alignment |
forms/ |
image_name |
"Title" | "Подпись к рисунку" (Caption) | ⚠️ Needs product decision — "Title" and "Caption" are different concepts; do not change without alignment |
yfm-layout/ |
action.align.left/center/right/stretch |
"Left alignment" (brief) vs "Вся секция по левому краю" (descriptive); "Stretch to the full width" vs "Растягивать секцию на всю ширину" | Expand EN: "Align entire section to the left / center / right / full width" | |
placeholder/ |
table_cell |
"Cell content" | "Текст" | Align both — "Text" / "Текст" to match layout_cell |
Step 3 — Fix English copy issues
| Location | Key | Problem | Fix |
|---|---|---|---|
forms/en.json |
image_link_href_help |
Typo: "Adress" | → "Address" |
menubar/en.json |
more_action |
"More action" (singular) | → "More actions" |
gpt/errors/en.json |
start-again-button |
"To the beginning" (word-for-word from RU) | → "Start over" |
bundle/en.json |
settings_hint |
Russian guillemets «+» in an English string | → "+" button |
Step 4 — Consolidate duplicate keysets
hints/ and math-hint/ have identical en.json and ru.json.
packages/editor/package.json has a ./_/* wildcard export mapping to build/esm/* and build/cjs/*, which means both paths (_/i18n/hints and _/i18n/math-hint) are technically externally reachable. To avoid a breaking change:
- Use
hints/as the canonical keyset — it has more internal consumers (items.tsx,wysiwyg.ts) vsmath-hint/which is used only inhint.tsx, so this minimises churn - Migrate all internal consumers to the canonical keyset
- Migrate
hint.tsx(sole consumer ofmath-hint) to import fromhints/instead; changemath-hint/index.tsto a thin re-export — this preserves_/i18n/math-hintmodule import compatibility - Add a
@deprecatedJSDoc comment on the re-export file
The en.json and ru.json files in the deprecated module are not deleted — only index.ts is changed to a re-export. Raw JSON subpath imports (_/i18n/hints/en.json) are therefore preserved physically as a side-effect.
Step 5 — Fix key naming inconsistency inside menubar + document convention
list_action_disabled uses a single underscore while neighboring keys use double underscore as a namespace separator (list__action_lift, list__action_sink). Rename to list__action_disabled and update all consumers.
Document the chosen convention (snake_case with __ as namespace separator) in docs/guidelines-contributions.md under a new "i18n keys" section. Repo-wide rename of other modules is out of scope for this issue.
Step 6 — Write and wire scripts/lint-i18n.mjs
Checks (exit non-zero on failure):
- For every module, all keys in
en.jsonexist inru.jsonand vice versa - No empty or whitespace-only values
- No value in
ru.jsonidentical to itsen.jsoncounterpart, except an allowlist of legitimate shared terms (product names, markup language names, etc.)
Advisory-only (print warnings, do not fail):
4. Duplicate values within the same locale file
Structure — two files, one purpose:
packages/editor/scripts/lint-i18n.js— linter logic as a CommonJS.jsmodule (returns structured errors); lives inscripts/alongsidecheck-circular-deps.js, outside runtime source tree and./_/*wildcard;.jsextension is importable by Jest without addingmjstomoduleFileExtensionsscripts/lint-i18n.js— thin root-level CommonJS runner (require()+process.exit(1));.jsnot.mjssorequire()is available natively withoutcreateRequire
Unit tests (packages/editor/src/i18n/__tests__/lint.test.ts): import the .js module, pass in-memory fixture objects — covers all lint rules as pure functions.
Integration smoke test (same file or separate lint.integration.test.ts): create a small temporary fixture directory on disk with 2–3 modules (one valid, one with a missing key, one with an empty value), run the full file-walk logic against it, assert exit behaviour — catches bugs in file discovery and module traversal that unit tests miss.
Add to root package.json scripts group (root lint already runs all lint:* via run-p, so no separate CI step needed):
"lint:i18n": "node scripts/lint-i18n.mjs"
Verification
Steps 1–3 (copy fixes):
pnpm lint:i18nexits 0pnpm testpasses
Step 1 (GPT try-again/refetch investigation):
- Confirm the target button's behavior by reading
GptDialog.tsxanduseGpt.tsx; add an assertion or snapshot covering the GPT dialog copy if none exists
Steps 4–5 (keyset consolidation + key rename):
pnpm lint:i18nexits 0- Grep for all consumers of the removed/renamed keys before and after to confirm no dangling references
- Add targeted unit tests for
MathHintconsumer andlist__action_disabledusage; key renames can break runtime without failing broad suite
Step 6 (lint script):
- Jest tests in
packages/editor/src/i18n/__tests__/lint.test.tspass - Introduce a deliberate key mismatch in a fixture object — test must fail
- Confirm
pnpm lint(root) picks uplint:i18nviarun-p
- 主要语言
- TypeScript
- 星标
- 428
- 派生
- 48
- 平均合并
- 5 天 15 小时
- 30 天内合并 PR
- 47
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
gravity-ui/markdown-editor 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
gravity-ui/markdown-editor#1452 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
gravity-ui/markdown-editor#1293 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
gravity-ui/markdown-editor#1129 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
gravity-ui/markdown-editor#1450 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
gravity-ui/markdown-editor#1331 ·
维护者通常 1 天内回复
查看 gravity-ui/markdown-editor 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
SocialGouv/egapro#5212 ·
维护者通常 2 天内回复
-
area:filesystem bug need-triage
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Captions panel does not offer to show an existing transcript可能已有人在做 @thedavidweng 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
CapSoftware/Cap#4276 · 1 条评论 ·
维护者通常 1 天内回复
-
bug from-app needs-triage
难度 2/5 1-3 小时 新手友好度 65/100
nightly-labs/openbot#10242 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复