Skip to content

i18n(pages): add Russian (ru) locale to the documentation site - #596

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
sescer:i18n/ru-locale
Jul 30, 2026
Merged

i18n(pages): add Russian (ru) locale to the documentation site#596
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
sescer:i18n/ru-locale

Conversation

@sescer

@sescer sescer commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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 had
no ru locale. This PR adds Russian UI strings and the first two docs pages.

Changes

  • Register ru in Language, language switcher (Navbar/Footer), and
    document.documentElement.lang
  • Add pages/src/i18n/ru.ts with full UI key coverage; derive
    TranslationKeys from the English literal so missing keys fail typecheck
  • Add pages/src/content/docs/ru/quickstart.md and installation.md
  • Support partial ruDocs with English fallback; keep zh/ja as full
    Record<DocSlug, string>
  • Fix docs search to iterate all English slugs so fallback pages remain
    searchable under ru
  • Include ru in DOCS_LOCALES for the translation-sync guard (+ tests)
  • Point README.ru-RU.md highlights/benchmark images at the new Russian
    assets and align terminology

Remaining docs markdown will land in follow-up PRs (2–4 pages each).

Verification

  • npm --prefix pages run lint
  • npm --prefix pages run typecheck
  • npm --prefix pages run build
  • npm --prefix pages run size
  • node scripts/github-actions/check-translation-sync.test.js
  • Manual smoke: language switcher → Русский; /, docs quickstart/installation,
    English fallback for other docs slugs, search (RU + EN queries)

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.
@CLAassistant

CLAassistant commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 1 issue(s) in this PR.

  • ✅ Successfully posted inline: 1 comment(s)

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work — this is one of the most thorough i18n PRs I've reviewed. A few things I particularly appreciate:

  • Deriving TranslationKeys from 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 the searchDocs fix to iterate all English slugs — this means Russian users can still search English-fallback pages, which is a detail many would overlook.
  • The LANG_BADGE record 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 ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n(pages): add Russian (ru) locale to the documentation site

3 participants