From 85280b52c2ea288c7659d7c8d895bac044520487 Mon Sep 17 00:00:00 2001 From: Xuepoo Date: Sat, 17 Oct 2026 19:26:58 +0800 Subject: [PATCH] [CTX-0068] feat(website): hero i18n IP detection, layout stabilization, and copy redesign --- src/components/LinuxDistroMatrix.astro | 50 +++- src/components/SiteHeader.astro | 46 +++- src/lib/translations.ts | 135 ++++++++++ src/pages/index.astro | 335 +++++++++++++++---------- 4 files changed, 418 insertions(+), 148 deletions(-) create mode 100644 src/lib/translations.ts diff --git a/src/components/LinuxDistroMatrix.astro b/src/components/LinuxDistroMatrix.astro index 7a42358..2f0649a 100644 --- a/src/components/LinuxDistroMatrix.astro +++ b/src/components/LinuxDistroMatrix.astro @@ -345,6 +345,18 @@ const families = [ { id: "source", label: "Void & Gentoo" }, { id: "universal", label: "Universal (AppImage / Flatpak / Snap)" }, ]; + +const filterI18nMap: Record = { + all: "filterAll", + arch: "filterArch", + debian: "filterDebian", + fedora: "filterFedora", + suse: "filterSuse", + alpine: "filterAlpine", + nix: "filterNix", + source: "filterSource", + universal: "filterUniversal", +}; ---
- + LINUX ECOSYSTEM - - ★ 全主流 Linux 发行版与包管理器支持 + + ★ Universal Linux Distribution & Package Support

Universal Linux Distribution Matrix

-

+

From bleeding-edge rolling releases (Arch, CachyOS) to stable enterprise deployments (Debian, Ubuntu, Fedora, openSUSE), lightweight musl systems (Alpine), and reproducible environments (NixOS)—Bitty runs natively @@ -380,17 +402,29 @@ const families = [

100%
-
NATIVE RUST
+
+ NATIVE RUST +
12
-
FORMATS & PKGS
+
+ FORMATS & PKGS +
0B
-
IDLE MEMORY
+
+ IDLE MEMORY +
@@ -415,7 +449,7 @@ const families = [ : "bg-[var(--bg-surface)] text-[var(--fg-secondary)] border-[var(--card-border)] hover:border-[var(--ink-border)] hover:text-[var(--fg-primary)]" }`} > - {f.label} + {f.label} ))} diff --git a/src/components/SiteHeader.astro b/src/components/SiteHeader.astro index 1de9555..157142f 100644 --- a/src/components/SiteHeader.astro +++ b/src/components/SiteHeader.astro @@ -176,9 +176,21 @@ const GITHUB_REPO_URL = "https://github.com/bitty-terminal/bitty"; const langBtn = document.getElementById("lang-toggle-btn"); const langLabel = document.getElementById("lang-current-label"); const pathname = window.location.pathname; - const isZh = pathname.includes("/zh-CN/") || pathname.endsWith("/zh-CN"); + const isZhDoc = pathname.includes("/zh-CN/") || pathname.endsWith("/zh-CN"); + const savedLang = (() => { + try { + return localStorage.getItem("bitty_lang"); + } catch { + return null; + } + })(); + const currentDocLang = + document.documentElement.getAttribute("data-lang") || + savedLang || + (isZhDoc ? "zh-CN" : "en"); if (langLabel) { - langLabel.textContent = isZh ? "中" : "EN"; + langLabel.textContent = + currentDocLang === "zh-CN" || isZhDoc ? "中" : "EN"; } langBtn?.addEventListener("click", () => { @@ -186,9 +198,15 @@ const GITHUB_REPO_URL = "https://github.com/bitty-terminal/bitty"; if (cur.includes("/docs/")) { if (cur.includes("/zh-CN/")) { // Switch zh-CN -> en + try { + localStorage.setItem("bitty_lang", "en"); + } catch {} window.location.href = cur.replace("/zh-CN/", "/"); } else { // Switch en -> zh-CN + try { + localStorage.setItem("bitty_lang", "zh-CN"); + } catch {} const match = cur.match(/^\/docs\/([^/]+)\/(.*)$/); if (match) { window.location.href = `/docs/${match[1]}/zh-CN/${match[2]}`; @@ -198,14 +216,26 @@ const GITHUB_REPO_URL = "https://github.com/bitty-terminal/bitty"; } } } else { - if (isZh) { - window.location.href = "/"; - } else { - window.location.href = - "/docs/latest/zh-CN/getting-started/quickstart/"; - } + // Toggle language on the homepage in-place + const curLang = + document.documentElement.getAttribute("data-lang") || "en"; + const nextLang = curLang === "zh-CN" ? "en" : "zh-CN"; + window.dispatchEvent( + new CustomEvent("bitty-lang-toggle", { + detail: { nextLang }, + }), + ); } }); + + // Listen for language update events + window.addEventListener("bitty-lang-updated", (( + e: CustomEvent<{ lang: string }>, + ) => { + if (langLabel && e.detail?.lang) { + langLabel.textContent = e.detail.lang === "zh-CN" ? "中" : "EN"; + } + }) as EventListener); })(); diff --git a/src/lib/translations.ts b/src/lib/translations.ts new file mode 100644 index 0000000..dcb34c1 --- /dev/null +++ b/src/lib/translations.ts @@ -0,0 +1,135 @@ +// src/lib/translations.ts +// Home & Hero i18n dictionaries for English (en) and Simplified Chinese (zh-CN). + +export type SupportedLang = "en" | "zh-CN"; + +export interface Translations { + heroBadge1: string; + heroBadge2: string; + heroTitle: string; + heroLede: string; + getBittyBtn: string; + exploreDocsBtn: string; + installDeckBadge: string; + installDeckChecksum: string; + installHintUnix: string; + installHintWin: string; + installHintPkg: string; + installHintCargo: string; + installHintDefault: string; + directBinariesTitle: string; + statusReady: string; + directMatrixLink: string; + linuxEcosystemBadge: string; + linuxEcosystemSubtitle: string; + linuxMatrixTitle: string; + linuxMatrixDesc: string; + statNativeRust: string; + statPackages: string; + statIdleMem: string; + filterAll: string; + filterArch: string; + filterDebian: string; + filterFedora: string; + filterSuse: string; + filterAlpine: string; + filterNix: string; + filterSource: string; + filterUniversal: string; + pillarsTitle: string; + pillarsSubtitle: string; + manualTitle: string; + manualSubtitle: string; +} + +export const translations: Record = { + en: { + heroBadge1: "★ GPU-ACCELERATED · RUST MICROKERNEL", + heroBadge2: "PICCOLO LUA SANDBOX · 0B IDLE", + heroTitle: "TILE SHELLS & RICH LUA PANELS AT NATIVE SPEED.", + heroLede: + "Bitty pairs Hyprland dwindle tiling with a pure-Rust microkernel. Run high-throughput PTY shells alongside declarative Piccolo Lua UI panels with zero background daemons.", + getBittyBtn: "Get Bitty ⚡", + exploreDocsBtn: "Explore Docs →", + installDeckBadge: "QUICK INSTALL", + installDeckChecksum: "SHA-256 CHECKSUMS ↗", + installHintUnix: + "Linux & macOS: Automated bootstrap fetching verified .tar.zst / binary", + installHintWin: + "Windows: PowerShell one-liner installing portable binary (user-local)", + installHintPkg: + "Package managers: Arch (AUR), Debian/Ubuntu (.deb), Fedora (.rpm), openSUSE, Alpine, NixOS, Flatpak", + installHintCargo: + "Build from source: compile with pinned toolchain (+1.98.1) via Cargo", + installHintDefault: "Automated bootstrap & verified checksums", + directBinariesTitle: "★ Direct R2 Binaries & Packages:", + statusReady: "● READY", + directMatrixLink: "Matrix ↓", + linuxEcosystemBadge: "LINUX ECOSYSTEM", + linuxEcosystemSubtitle: "★ Universal Linux Distribution & Package Support", + linuxMatrixTitle: "Universal Linux Distribution Matrix", + linuxMatrixDesc: + "From bleeding-edge rolling releases (Arch, CachyOS) to stable enterprise deployments (Debian, Ubuntu, Fedora, openSUSE), lightweight musl systems (Alpine), and reproducible environments (NixOS)—Bitty runs natively everywhere.", + statNativeRust: "100% NATIVE RUST", + statPackages: "12 FORMATS & PKGS", + statIdleMem: "0B IDLE MEMORY", + filterAll: "All Formats (12)", + filterArch: "Arch / CachyOS", + filterDebian: "Debian / Ubuntu", + filterFedora: "Fedora / RHEL", + filterSuse: "openSUSE", + filterAlpine: "Alpine (musl)", + filterNix: "NixOS", + filterSource: "Void & Gentoo", + filterUniversal: "Universal (AppImage / Flatpak / Snap)", + pillarsTitle: "Engineered for Composability & Isolation", + pillarsSubtitle: + "Zero monolithic bloat. Bitty separates terminal mechanics from extension policy.", + manualTitle: "Bitty Manual & Guides", + manualSubtitle: + "Official user manual, configuration reference, and Lua API documentation served directly from Cloudflare R2.", + }, + "zh-CN": { + heroBadge1: "GPU 加速微内核架构", + heroBadge2: "PICCOLO LUA 隔离沙箱 · 0B 空闲内存", + heroTitle: "平铺分屏与丰富 LUA 面板,原生极速终端", + heroLede: + "Bitty 将 Hyprland 风格的平铺分屏与纯 Rust 微内核深度结合。支持高吞吐 PTY 终端会话与声明式 Piccolo Lua UI 面板并存,零后台守护进程常驻。", + getBittyBtn: "安装 Bitty ⚡", + exploreDocsBtn: "浏览官方文档 →", + installDeckBadge: "快速安装", + installDeckChecksum: "SHA-256 校验和 ↗", + installHintUnix: "Linux & macOS: 自动拉取已验证的 .tar.zst 二进制包", + installHintWin: "Windows: PowerShell 单行命令安装便携二进制(用户本地)", + installHintPkg: + "发行版包管理器: Arch (AUR), Debian/Ubuntu (.deb), Fedora (.rpm), openSUSE, Alpine, NixOS, Flatpak", + installHintCargo: "从源码编译: 通过 Cargo 与锁定工具链 (+1.98.1) 本地构建", + installHintDefault: "自动化安装脚本 · 官方校验和已验证", + directBinariesTitle: "★ R2 官方构建包与发行版安装包:", + statusReady: "● 就绪", + directMatrixLink: "发行版矩阵 ↓", + linuxEcosystemBadge: "LINUX 发行版生态", + linuxEcosystemSubtitle: "★ 全主流 Linux 发行版与包管理器原生支持", + linuxMatrixTitle: "全主流 Linux 发行版支持矩阵", + linuxMatrixDesc: + "无论是前沿滚动的 Arch、CachyOS,还是企业级稳定的 Debian、Ubuntu、Fedora、openSUSE,亦或是轻量 musl 系统(Alpine)与纯净重现式构建(NixOS)——Bitty 原生兼容一切。", + statNativeRust: "100% 纯 RUST 原生", + statPackages: "12 种打包格式", + statIdleMem: "0B 空闲内存占用", + filterAll: "全格式 (12)", + filterArch: "Arch / CachyOS", + filterDebian: "Debian / Ubuntu", + filterFedora: "Fedora / RHEL", + filterSuse: "openSUSE", + filterAlpine: "Alpine (musl)", + filterNix: "NixOS", + filterSource: "Void & Gentoo", + filterUniversal: "通用格式 (AppImage / Flatpak / Snap)", + pillarsTitle: "专为高度组合与沙箱隔离设计", + pillarsSubtitle: + "拒绝单体臃肿设计。Bitty 将终端渲染核心与扩展业务逻辑彻底分离。", + manualTitle: "Bitty 官方手册与指南", + manualSubtitle: + "官方用户手册、配置规范与 Lua API 文档,通过 Cloudflare R2 极速直连分发。", + }, +}; diff --git a/src/pages/index.astro b/src/pages/index.astro index dc5eb8e..cae4931 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -79,6 +79,20 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; } } catch {} document.documentElement.setAttribute("data-theme", theme); + + try { + const savedLang = localStorage.getItem("bitty_lang"); + if (savedLang === "zh-CN" || savedLang === "en") { + document.documentElement.setAttribute("data-lang", savedLang); + } else if ( + navigator.language && + navigator.language.startsWith("zh") + ) { + document.documentElement.setAttribute("data-lang", "zh-CN"); + } else { + document.documentElement.setAttribute("data-lang", "en"); + } + } catch {} })(); @@ -91,22 +105,25 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? [];
- +
- +
- ★ - 超高速 GPU 端末 // MICROKERNEL + + ★ GPU-ACCELERATED · RUST MICROKERNEL + - PICCOLO LUA VM · 0B IDLE + + PICCOLO LUA SANDBOX · 0B IDLE +
@@ -114,62 +131,20 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? [];

- TILE SHELLS & RICH LUA GUIS AT ARCADE SPEED. + TILE SHELLS & RICH LUA PANELS AT NATIVE SPEED.

-

- Bitty brings Hyprland-style dwindle tiling into - a pure-Rust microkernel terminal. Every panel hosts either a raw - PTY stream or a sandboxed Piccolo Lua GUI—backed by zero-daemon - native coprocesses. +

+ Bitty pairs Hyprland dwindle tiling with a pure-Rust + microkernel. Run high-throughput PTY shells alongside + declarative Piccolo Lua UI panels with zero background daemons.

- -
- -
-
- - Bittie Navigator // bitty --mascot - - -
-

- "Oha~! Press [Alt+E] to pop open the Composer modal, or - click my face to cycle terminal tips!" -

-
-
-
@@ -196,13 +170,24 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? [];
- - INSTALL DECK + + QUICK INSTALL - 導入カートリッジ // SHA-256 + + SHA-256 CHECKSUMS ↗ +
- v0.0.23 · R2 CDN + R2 CDN
@@ -271,10 +256,7 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; role="tabpanel" aria-labelledby="dl-tab-unix" > -
+
g.id === "api")?.entries ?? [];
-
- +
+ Linux & macOS: Automated bootstrap fetching verified .tar.zst / binary -
@@ -310,7 +296,10 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? [];
- + ★ Direct R2 Binaries & Packages: g.id === "api")?.entries ?? []; href="#linux-distros" class="text-[9px] text-[var(--accent)] hover:underline font-bold" title="Jump to full Linux Distros Matrix" + data-i18n="directMatrixLink" > Matrix ↓ @@ -459,10 +449,14 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? [];

Engineered for Composability & Isolation

-

+

Zero monolithic bloat. Bitty separates terminal mechanics from extension policy.

@@ -476,7 +470,9 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; STAGE 01 - 画面分割 // TILING + + TILING & PANELS +

Hyprland Tiling × GUI Panels @@ -507,7 +503,7 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; STAGE 02 - 二重拡張 // EXTENSIONS + PICCOLO & WIRE V1

@@ -539,7 +535,7 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; STAGE 03 - 即時反映 // LIVE LUA + HOT RELOAD & RECOVERY

@@ -578,10 +574,14 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? [];

Bitty Manual & Guides

-

+

Official user manual, configuration reference, and Lua API documentation served directly from Cloudflare R2.

@@ -715,47 +715,15 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; @@ -874,7 +929,7 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; @media (min-width: 64rem) { .hero-grid { - grid-template-columns: 7fr 5fr; + grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); } } @@ -885,6 +940,14 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; box-sizing: border-box; } + .no-scrollbar { + scrollbar-width: none; + -ms-overflow-style: none; + } + .no-scrollbar::-webkit-scrollbar { + display: none; + } + .dl-tab { min-height: 2.25rem; height: 2.25rem; @@ -892,6 +955,14 @@ const apiDocs = manualGroups.find((g) => g.id === "api")?.entries ?? []; display: inline-flex; align-items: center; justify-content: center; + transition: all 0.15s ease; + } + + .dl-tab.active { + background: var(--accent) !important; + color: #0b0914 !important; + border-color: var(--ink-border) !important; + box-shadow: 2px 2px 0px var(--toon-shadow); } .hero-lede {