cmux/web/app/[locale]/docs/concepts/page.tsx
Lawrence Chen cf75da8f8a
Internationalize website with next-intl for 19 languages (#1216)
* Add i18n framework with next-intl for 19 languages

Set up complete internationalization infrastructure:
- Install next-intl v4 with App Router support
- Create i18n config (routing, request, navigation)
- Add middleware for automatic locale detection from Accept-Language
- Restructure all routes under app/[locale]/
- Extract UI strings to messages/en.json
- Update all components to use useTranslations()
- Add language switcher dropdown in footer
- Support RTL for Arabic and Khmer
- Update sitemap with locale alternates
- Add generateStaticParams for all 19 locales

Languages: en, ja, zh-CN, zh-TW, ko, de, es, fr, it, da, pl, ru, bs, ar, no, pt-BR, th, tr, km

Locale detection: auto-detect from browser Accept-Language header,
with cookie persistence and locale prefix only for non-default (en).

* Add translations for de, fr, it, ja, zh-CN, zh-TW

* Add translations for ar, bs, da, es, km, no, pl, pt-BR, ru, th, tr

* Convert docs and legal pages to use useTranslations()

* Add i18n to keyboard shortcuts component

* Add i18n to wall-of-love, add missing blog posts to sitemap

* Add keyboard shortcuts and wallOfLove translations to all locales

* Update bun lockfile for next-intl dependency

* Fix t.rich() configPath: pass ReactNode not function for {var} interpolation

* Fix configPath: use rich text tag instead of plain interpolation for ReactNode

* Fix t.rich() interpolation: use rich text tags for all ReactNode placeholders

Changed {legacy}, {openShortcut}, {jumpShortcut} from plain variable
interpolation to <tag>content</tag> format so t.rich() gets proper
functions instead of values.

* Escape ICU curly braces in socketCallout rich text across all locales

* Fix i18n issues: Khmer RTL, zh-CN quality, locale-aware testimonials, hardcoded strings

- Fix Khmer (km) incorrectly marked as RTL (it's LTR, only Arabic is RTL)
- Fix zh-CN/zh-TW taglinePrefix to mention terminals and open source
- Add locale-aware testimonial translations: show original text, translate
  for non-matching locales, skip translation when locale matches original
- Translate hardcoded English table content in notifications page
- Add testimonial translations to all 19 locale files
- Remove unused setRequestLocale import and params from home page

* Address PR review comments: metadata localization, blog fixes, legal pages, accessibility

- Convert hardcoded metadata to generateMetadata with getTranslations on all docs, blog, community, and wall-of-love pages
- Fix blog canonical/OG URLs to be locale-aware
- Fix introducing-cmux .split(": ") by using separate label/desc translation keys
- Revert legal page titles to English (legal content stays English-only)
- Add focus-visible ring to language switcher for keyboard accessibility
- Preserve query string and hash when switching locale
- Convert site-footer to server component (remove unnecessary "use client")
- Remove .toLowerCase() on translated text in community page
- Add /docs/browser-automation and /wall-of-love to sitemap
- Fix keyboard-shortcuts jump link visibility with trimmed query
- Deduplicate blogSlugs by importing from blog-posts.ts
- Add typingCodingAgents/typingMultitasking translation keys to all locales
- Fix Spanish accent/tilde issues in es.json testimonials
- Fix nested <a> tag in homepage keyboard shortcuts feature
- Remove unused setRequestLocale import from homepage

* Convert remaining layout/index metadata to generateMetadata

- Root layout: locale-aware title, description, OG, and Twitter card metadata
- Docs layout: translated title template
- Blog layout: translated title template
- Blog index: locale-aware metadata

* Add translated metadata keys to all locales, fix docs redirect

- Add meta.title/description/ogDescription to all 18 non-English locales
- Add docs.layoutTitle, blog.layoutTitle/metaTitle/metaDescription to all locales
- Add blog post metadata (zenOfCmux, cmdShiftU, showHnLaunch, introducingCmux) to all locales
- Add community.metaTitle/metaDescription to all locales
- Fix docs index redirect to preserve locale prefix

* Add translated docs page metaTitle keys to all locales
2026-03-12 05:36:58 -07:00

193 lines
5.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useTranslations } from "next-intl";
import { getTranslations } from "next-intl/server";
import { CodeBlock } from "../../components/code-block";
export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
const { locale } = await params;
const t = await getTranslations({ locale, namespace: "docs.concepts" });
return {
title: t("metaTitle"),
description: t("metaDescription"),
};
}
export default function ConceptsPage() {
const t = useTranslations("docs.concepts");
return (
<>
<h1>{t("title")}</h1>
<p>{t("intro")}</p>
<h2>{t("hierarchy")}</h2>
<CodeBlock lang="text">{`Window
└── Workspace (sidebar entry)
└── Pane (split region)
└── Surface (tab within pane)
└── Panel (terminal or browser content)`}</CodeBlock>
<h3>{t("windowTitle")}</h3>
<p>
{t("windowDesc", { shortcut: "⌘⇧N" })}
</p>
<h3>{t("workspaceTitle")}</h3>
<p>{t("workspaceDesc")}</p>
<p>{t("workspaceNote")}</p>
<table>
<thead>
<tr>
<th>{t("contextHeader")}</th>
<th>{t("termUsedHeader")}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{t("sidebarUI")}</td>
<td>{t("tab")}</td>
</tr>
<tr>
<td>{t("keyboardShortcuts")}</td>
<td>{t("workspaceOrTab")}</td>
</tr>
<tr>
<td>{t("socketAPI")}</td>
<td>
<code>workspace</code>
</td>
</tr>
<tr>
<td>{t("environmentVariable")}</td>
<td>
<code>CMUX_WORKSPACE_ID</code>
</td>
</tr>
</tbody>
</table>
<p>
<strong>
{t("workspaceShortcuts", {
new: "⌘N",
jump: "⌘1⌘9",
close: "⌘⇧W",
prevNext: "⌘⇧[ / ⌘⇧]",
})}
</strong>
</p>
<h3>{t("paneTitle")}</h3>
<p>
{t("paneDesc", {
right: "⌘D",
down: "⌘⇧D",
nav: "⌥⌘",
})}
</p>
<p>{t("paneNote")}</p>
<h3>{t("surfaceTitle")}</h3>
<p>
{t("surfaceDesc", {
new: "⌘T",
prev: "⌘[",
next: "⌘]",
jump: "⌃1⌃9",
})}
</p>
<p>{t("surfaceNote")}</p>
<h3>{t("panelTitle")}</h3>
<p>{t("panelDesc")}</p>
<ul>
<li>
<strong>{t("panelTerminal")}</strong>
</li>
<li>
<strong>{t("panelBrowser")}</strong>
</li>
</ul>
<p>{t("panelNote")}</p>
<h2>{t("visualExample")}</h2>
<CodeBlock variant="ascii">{`┌──────────────────────────────────────────────────────┐
│ ┌──────────┐ ┌─────────────────────────────────────┐ │
│ │ Sidebar │ │ Workspace "dev" │ │
│ │ │ │ │ │
│ │ │ │ ┌───────────────┬─────────────────┐ │ │
│ │ > dev │ │ │ Pane 1 │ Pane 2 │ │ │
│ │ server │ │ │ [S1] [S2] │ [S1] │ │ │
│ │ logs │ │ │ │ │ │ │
│ │ │ │ │ Terminal │ Terminal │ │ │
│ │ │ │ │ │ │ │ │
│ │ │ │ └───────────────┴─────────────────┘ │ │
│ └──────────┘ └─────────────────────────────────────┘ │
└──────────────────────────────────────────────────────┘`}</CodeBlock>
<p>{t("visualExampleDesc")}</p>
<ul>
<li>{t("visualItem1")}</li>
<li>{t("visualItem2")}</li>
<li>{t("visualItem3")}</li>
<li>{t("visualItem4")}</li>
<li>{t("visualItem5")}</li>
</ul>
<h2>{t("summary")}</h2>
<table>
<thead>
<tr>
<th>{t("levelHeader")}</th>
<th>{t("whatItIsHeader")}</th>
<th>{t("createdByHeader")}</th>
<th>{t("identifiedByHeader")}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{t("windowTitle")}</td>
<td>{t("macosWindow")}</td>
<td>
<code>N</code>
</td>
<td></td>
</tr>
<tr>
<td>{t("workspaceTitle")}</td>
<td>{t("sidebarEntry")}</td>
<td>
<code>N</code>
</td>
<td>
<code>CMUX_WORKSPACE_ID</code>
</td>
</tr>
<tr>
<td>{t("paneTitle")}</td>
<td>{t("splitRegion")}</td>
<td>
<code>D</code> / <code>D</code>
</td>
<td>{t("paneIdSocket")}</td>
</tr>
<tr>
<td>{t("surfaceTitle")}</td>
<td>{t("tabWithinPane")}</td>
<td>
<code>T</code>
</td>
<td>
<code>CMUX_SURFACE_ID</code>
</td>
</tr>
<tr>
<td>{t("panelTitle")}</td>
<td>{t("terminalOrBrowser")}</td>
<td>{t("automatic")}</td>
<td>{t("panelIdInternal")}</td>
</tr>
</tbody>
</table>
</>
);
}