i18n(pages): add Russian (ru) locale to the documentation site - #596
Conversation
Wire ru into the docs site language switcher and i18n strings, add quickstart/installation translations, README Russian screenshots, and include ru in the docs translation-sync guard. Remaining docs pages fall back to English.
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
|
| function getRawContent(slug: DocSlug, language: string): string { | ||
| const langDocs = docsMap[language] || docsMap.en; | ||
| return langDocs[slug] || enDocs[slug] || ''; | ||
| const langDocs = docsMap[language as Language] || docsMap.en; |
There was a problem hiding this comment.
[maintainability · low]
The as Language type assertion bypasses TypeScript's type checking. If an unrecognized language string is passed at runtime, docsMap[language as Language] returns undefined and silently falls back to English via || docsMap.en. While this works, consider using a safer lookup pattern that doesn't require a type assertion, e.g.:
const langDocs = (language in docsMap ? docsMap[language as Language] : undefined) || docsMap.en;Or better yet, accept Language instead of string as the parameter type so callers are forced to pass valid values. The same applies to the identical pattern in searchDocs below.
lizhengfeng101
left a comment
There was a problem hiding this comment.
Great work — this is one of the most thorough i18n PRs I've reviewed. A few things I particularly appreciate:
- Deriving
TranslationKeysfrom the English literal (as const) so missing keys in any locale fail at compile time — a nice type-safety win that goes beyond just adding a locale. - The partial-locale fallback design (
LocalizedDocs) with thesearchDocsfix to iterate all English slugs — this means Russian users can still search English-fallback pages, which is a detail many would overlook. - The
LANG_BADGErecord replacing the ternary chain — cleaner and scales effortlessly. - Tests updated correctly, translation-sync guard extended, CI workflow comments aligned.
The Russian copy reads naturally and the terminology choices (пул-реквест, ИИ-агент, субагент) are consistent throughout.
Отличная работа — один из самых тщательных i18n-PR, которые я видел. Отдельно хочу отметить:
- Вывод
TranslationKeysиз английского литерала (as const) — пропущенные ключи в любой локали теперь ломают сборку на этапе компиляции. Это не просто добавление локали, а улучшение типобезопасности всего проекта. - Продуманный механизм частичной локализации (
LocalizedDocs) с фоллбэком на английский, включая исправление поиска — русскоязычные пользователи могут искать по страницам, которые ещё не переведены. Такую деталь легко упустить. - Замена цепочки тернарных операторов на
LANG_BADGE— чище и масштабируется без усилий. - Тесты обновлены корректно, translation-sync guard расширен, комментарии в CI-воркфлоу приведены в соответствие.
Русский текст читается естественно, терминология (пул-реквест, ИИ-агент, субагент) выдержана единообразно.
LGTM ✅
Fixes #423
Background
The docs site (
pages/) already supports English, Chinese, and Japanese.The README has a Russian translation (
README.ru-RU.md), but the site hadno
rulocale. This PR adds Russian UI strings and the first two docs pages.Changes
ruinLanguage, language switcher (Navbar/Footer), anddocument.documentElement.langpages/src/i18n/ru.tswith full UI key coverage; deriveTranslationKeysfrom the English literal so missing keys fail typecheckpages/src/content/docs/ru/quickstart.mdandinstallation.mdruDocswith English fallback; keepzh/jaas fullRecord<DocSlug, string>searchable under
ruruinDOCS_LOCALESfor the translation-sync guard (+ tests)README.ru-RU.mdhighlights/benchmark images at the new Russianassets and align terminology
Remaining docs markdown will land in follow-up PRs (2–4 pages each).
Verification
npm --prefix pages run lintnpm --prefix pages run typechecknpm --prefix pages run buildnpm --prefix pages run sizenode scripts/github-actions/check-translation-sync.test.js/, docs quickstart/installation,English fallback for other docs slugs, search (RU + EN queries)