cmux/web/app/[locale]/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

310 lines
10 KiB
TypeScript

import { useTranslations, useLocale } from "next-intl";
import { FadeImage } from "./components/fade-image";
import Balancer from "react-wrap-balancer";
import landingImage from "./assets/landing-image.png";
import { TypingTagline } from "./typing";
import { DownloadButton } from "./components/download-button";
import { GitHubButton } from "./components/github-button";
import { SiteHeader } from "./components/site-header";
import { testimonials, getTestimonialTranslation } from "./testimonials";
import { Link } from "../../i18n/navigation";
export default function Home() {
return <HomeContent />;
}
function HomeContent() {
const t = useTranslations("home");
const tc = useTranslations("common");
const tt = useTranslations("testimonials");
const locale = useLocale();
const linkClass =
"underline underline-offset-2 decoration-border hover:decoration-foreground transition-colors";
return (
<div className="min-h-screen">
<SiteHeader hideLogo />
<main className="w-full max-w-2xl mx-auto px-6 py-16 sm:py-24">
{/* Header */}
<div className="flex items-center gap-4 mb-10" data-dev="header">
<img
src="/logo.png"
alt="cmux icon"
width={48}
height={48}
className="rounded-xl"
/>
<h1 className="text-2xl font-semibold tracking-tight">cmux</h1>
</div>
{/* Tagline */}
<p className="text-lg leading-relaxed mb-3 text-foreground">
{t("taglinePrefix")}
<TypingTagline />
</p>
<p
className="text-base text-muted"
data-dev="subtitle"
style={{ lineHeight: 1.5 }}
>
<Balancer>{t("subtitle")}</Balancer>
</p>
{/* Download */}
<div
className="flex flex-wrap items-center gap-3"
data-dev="download"
style={{ marginTop: 21, marginBottom: 16 }}
>
<DownloadButton location="hero" />
<GitHubButton />
</div>
{/* Features */}
<section
data-dev="features"
style={{ paddingTop: 12, paddingBottom: 15 }}
>
<h2 className="text-xs font-medium text-muted tracking-tight mb-3">
{t("features")}
</h2>
<ul
className="space-y-3 text-[15px]"
data-dev="features-ul"
style={{ lineHeight: 1.275 }}
>
{(
[
["verticalTabs", "verticalTabsDesc"],
["notificationRings", "notificationRingsDesc"],
["inAppBrowser", "inAppBrowserDesc"],
["splitPanes", "splitPanesDesc"],
["scriptable", "scriptableDesc"],
["gpuAccelerated", "gpuAcceleratedDesc"],
["lightweight", "lightweightDesc"],
] as const
).map(([title, desc]) => (
<li key={title} className="flex gap-3">
<span className="text-muted shrink-0">-</span>
<span>
<strong className="font-medium">
{t(`feature.${title}`)}
</strong>
<span className="text-muted">{t(`feature.${desc}`)}</span>
</span>
</li>
))}
<li className="flex gap-3">
<span className="text-muted shrink-0">-</span>
<span>
<strong className="font-medium">
{t("feature.keyboardShortcuts")}
</strong>
<span className="text-muted">
{t.rich("feature.keyboardShortcutsDesc", {
link: (chunks) => (
<a
href="/docs/keyboard-shortcuts"
className={linkClass}
>
{chunks}
</a>
),
})}
</span>
</span>
</li>
</ul>
</section>
{/* Screenshot */}
<div
data-dev="screenshot"
className="mb-12 -mx-6 sm:-mx-24 md:-mx-40 lg:-mx-72 xl:-mx-96"
>
<FadeImage
src={landingImage}
alt="cmux terminal app screenshot"
priority
className="w-full rounded-xl"
/>
</div>
{/* FAQ */}
<div data-dev="faq-top-spacer" style={{ height: 0 }} />
<section data-dev="faq" className="mb-10">
<h2 className="text-xs font-medium text-muted tracking-tight mb-3">
{t("faq")}
</h2>
<div
className="space-y-5 text-[15px]"
style={{ lineHeight: 1.5 }}
>
<div>
<p className="font-medium mb-1">{t("faqGhosttyQ")}</p>
<p className="text-muted">
{t.rich("faqGhosttyA", {
link: (chunks) => (
<a
href="https://github.com/ghostty-org/ghostty"
className={linkClass}
>
{chunks}
</a>
),
})}
</p>
</div>
<div>
<p className="font-medium mb-1">{t("faqPlatformQ")}</p>
<p className="text-muted">{t("faqPlatformA")}</p>
</div>
<div>
<p className="font-medium mb-1">{t("faqAgentsQ")}</p>
<p className="text-muted">{t("faqAgentsA")}</p>
</div>
<div>
<p className="font-medium mb-1">{t("faqNotificationsQ")}</p>
<p className="text-muted">
{t.rich("faqNotificationsA", {
cliLink: (chunks) => (
<a href="/docs/notifications" className={linkClass}>
{chunks}
</a>
),
hooksLink: (chunks) => (
<a href="/docs/notifications" className={linkClass}>
{chunks}
</a>
),
})}
</p>
</div>
<div>
<p className="font-medium mb-1">{t("faqShortcutsQ")}</p>
<p className="text-muted">
{t.rich("faqShortcutsA", {
configPath: (chunks) => (
<code className="text-xs bg-code-bg px-1.5 py-0.5 rounded">
{chunks}
</code>
),
link: (chunks) => (
<a href="/docs/keyboard-shortcuts" className={linkClass}>
{chunks}
</a>
),
})}
</p>
</div>
<div>
<p className="font-medium mb-1">{t("faqTmuxQ")}</p>
<p className="text-muted">{t("faqTmuxA")}</p>
</div>
<div>
<p className="font-medium mb-1">{t("faqFreeQ")}</p>
<p className="text-muted">
{t.rich("faqFreeA", {
link: (chunks) => (
<a
href="https://github.com/manaflow-ai/cmux"
className={linkClass}
>
{chunks}
</a>
),
})}
</p>
</div>
</div>
</section>
{/* Community */}
<section data-dev="community" className="mb-10">
<h2 className="text-xs font-medium text-muted tracking-tight mb-3">
{t("communitySection")}
</h2>
<ul
data-dev="community-ul"
className="text-[15px]"
style={{
lineHeight: 1.5,
display: "flex",
flexDirection: "column",
gap: 16,
}}
>
{testimonials.map((item) => {
const translation = getTestimonialTranslation(item, locale, tt);
return (
<li key={item.url}>
<span>
<a
href={item.url}
target="_blank"
rel="noopener noreferrer"
className="group"
>
<span className="text-muted group-hover:text-foreground transition-colors">
&quot;{item.text}&quot;
</span>
{translation && (
<span className="text-muted/60 text-xs italic">
{" "}
{translation}
</span>
)}
</a>{" "}
<a
href={item.url}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 text-muted hover:text-foreground transition-colors"
>
{item.avatar && (
<img
src={item.avatar}
alt={item.name}
width={16}
height={16}
className="rounded-full inline-block"
/>
)}
{item.name}
{"subtitle" in item && item.subtitle
? `, ${item.subtitle}`
: ""}
</a>
</span>
</li>
);
})}
</ul>
</section>
{/* Bottom CTA */}
<div className="flex flex-wrap items-center justify-center gap-3 mt-12">
<DownloadButton location="bottom" />
<GitHubButton />
</div>
<div className="flex justify-center gap-4 mt-6">
<Link
href="/docs"
className="text-sm text-muted hover:text-foreground transition-colors underline underline-offset-2 decoration-border hover:decoration-foreground"
>
{tc("readTheDocs")}
</Link>
<Link
href="/docs/changelog"
className="text-sm text-muted hover:text-foreground transition-colors underline underline-offset-2 decoration-border hover:decoration-foreground"
>
{tc("viewChangelog")}
</Link>
</div>
</main>
</div>
);
}