diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-06 04:53:05 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-06 04:54:21 +0300 |
| commit | d36a6ded3bbc623a3fcad3c6e45b7b22ae9b6267 (patch) | |
| tree | 2777d83cbb67ebc2cabd6bffe5e22432c490f62b /website/astro.config.mjs | |
| parent | b04c6496a8c08059b8cc83ab29a51023f16c76cd (diff) | |
feat(website): add japanese and simplified chinese docs with i18n, translation issue flow
Diffstat (limited to 'website/astro.config.mjs')
| -rw-r--r-- | website/astro.config.mjs | 82 |
1 files changed, 64 insertions, 18 deletions
diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 1f30a8dc..6e981d8c 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -49,11 +49,21 @@ function walk(node, visitor) { export default defineConfig({ site: 'https://herdr.dev', + redirects: { + '/ja': '/ja/docs/', + '/zh-cn': '/zh-cn/docs/', + }, integrations: [ starlight({ title: 'herdr', description: 'Terminal-native agent runtime and multiplexer.', favicon: '/assets/favicon.png?v=14', + defaultLocale: 'root', + locales: { + root: { label: 'English', lang: 'en' }, + ja: { label: '日本語', lang: 'ja' }, + 'zh-cn': { label: '简体中文', lang: 'zh-CN' }, + }, social: [ { icon: 'github', @@ -62,6 +72,7 @@ export default defineConfig({ }, ], components: { + Banner: './src/components/Banner.astro', Header: './src/components/Header.astro', Sidebar: './src/components/Sidebar.astro', SiteTitle: './src/components/SiteTitle.astro', @@ -69,6 +80,36 @@ export default defineConfig({ customCss: ['./src/styles/starlight.css'], head: [ { + // First-visit locale redirect: honors browser language order, then + // remembers the last locale the reader actually used. + tag: 'script', + content: `(function () { + try { + var KEY = 'herdr-docs-lang'; + var path = location.pathname; + var m = path.match(/^\\/(ja|zh-cn)(?=\\/|$)/); + var current = m ? m[1] : path.indexOf('/docs') === 0 ? 'en' : null; + if (!current) return; + if (!localStorage.getItem(KEY) && current === 'en') { + var langs = navigator.languages && navigator.languages.length ? navigator.languages : [navigator.language || '']; + var target = null; + for (var i = 0; i < langs.length && !target; i++) { + var l = String(langs[i]).toLowerCase(); + if (l === 'ja' || l.indexOf('ja-') === 0) target = 'ja'; + else if (l === 'zh' || l.indexOf('zh-') === 0) target = 'zh-cn'; + else if (l.indexOf('en') === 0) break; + } + if (target) { + localStorage.setItem(KEY, target); + location.replace('/' + target + path + location.search + location.hash); + return; + } + } + localStorage.setItem(KEY, current); + } catch (e) {} +})();`, + }, + { tag: 'meta', attrs: { property: 'og:image', content: 'https://herdr.dev/assets/og-card-v8.png' }, }, @@ -101,45 +142,50 @@ export default defineConfig({ sidebar: [ { label: 'Start here', + translations: { ja: 'はじめに', 'zh-CN': '从这里开始' }, items: [ - { label: 'Overview', slug: 'docs' }, - { label: 'Install', slug: 'docs/install' }, - { label: 'Quick start', slug: 'docs/quick-start' }, - { label: 'Concepts', slug: 'docs/concepts' }, - { label: 'Keyboard', slug: 'docs/keyboard' }, - { label: 'How to work with Herdr', slug: 'docs/how-to-work' }, + { label: 'Overview', translations: { ja: '概要', 'zh-CN': '概览' }, slug: 'docs' }, + { label: 'Install', translations: { ja: 'インストール', 'zh-CN': '安装' }, slug: 'docs/install' }, + { label: 'Quick start', translations: { ja: 'クイックスタート', 'zh-CN': '快速开始' }, slug: 'docs/quick-start' }, + { label: 'Concepts', translations: { ja: 'コンセプト', 'zh-CN': '核心概念' }, slug: 'docs/concepts' }, + { label: 'Keyboard', translations: { ja: 'キーボード', 'zh-CN': '键盘' }, slug: 'docs/keyboard' }, + { label: 'How to work with Herdr', translations: { ja: 'Herdr での作業の進め方', 'zh-CN': '使用 Herdr 的工作方式' }, slug: 'docs/how-to-work' }, ], }, { label: 'Core guides', + translations: { ja: 'コアガイド', 'zh-CN': '核心指南' }, items: [ - { label: 'Agents', slug: 'docs/agents' }, - { label: 'Session state and restore', slug: 'docs/session-state' }, - { label: 'Persistence and remote access', slug: 'docs/persistence-remote' }, - { label: 'Configuration', slug: 'docs/configuration' }, + { label: 'Agents', translations: { ja: 'エージェント', 'zh-CN': '智能体' }, slug: 'docs/agents' }, + { label: 'Session state and restore', translations: { ja: 'セッション状態と復元', 'zh-CN': '会话状态与恢复' }, slug: 'docs/session-state' }, + { label: 'Persistence and remote access', translations: { ja: '永続化とリモートアクセス', 'zh-CN': '持久化与远程访问' }, slug: 'docs/persistence-remote' }, + { label: 'Configuration', translations: { ja: '設定', 'zh-CN': '配置' }, slug: 'docs/configuration' }, ], }, { label: 'Plugins', + translations: { ja: 'プラグイン', 'zh-CN': '插件' }, items: [ - { label: 'Plugins', slug: 'docs/plugins' }, - { label: 'Marketplace', slug: 'docs/marketplace' }, + { label: 'Plugins', translations: { ja: 'プラグイン', 'zh-CN': '插件' }, slug: 'docs/plugins' }, + { label: 'Marketplace', translations: { ja: 'マーケットプレイス', 'zh-CN': '插件市场' }, slug: 'docs/marketplace' }, ], }, { label: 'Reference', + translations: { ja: 'リファレンス', 'zh-CN': '参考' }, items: [ - { label: 'CLI reference', slug: 'docs/cli-reference' }, - { label: 'Socket API', slug: 'docs/socket-api' }, - { label: 'Integrations', slug: 'docs/integrations' }, - { label: 'Agent skill file', slug: 'docs/agent-skill' }, - { label: 'Windows beta', slug: 'docs/windows-beta' }, + { label: 'CLI reference', translations: { ja: 'CLI リファレンス', 'zh-CN': 'CLI 参考' }, slug: 'docs/cli-reference' }, + { label: 'Socket API', translations: { ja: 'ソケット API', 'zh-CN': 'Socket API' }, slug: 'docs/socket-api' }, + { label: 'Integrations', translations: { ja: 'インテグレーション', 'zh-CN': '集成' }, slug: 'docs/integrations' }, + { label: 'Agent skill file', translations: { ja: 'エージェントスキルファイル', 'zh-CN': '智能体技能文件' }, slug: 'docs/agent-skill' }, + { label: 'Windows beta', translations: { ja: 'Windows ベータ', 'zh-CN': 'Windows 测试版' }, slug: 'docs/windows-beta' }, ], }, { label: 'Updates', + translations: { ja: '更新情報', 'zh-CN': '更新' }, items: [ - { label: 'Preview docs', slug: 'docs/preview' }, + { label: 'Preview docs', translations: { ja: 'プレビュー版ドキュメント', 'zh-CN': '预览版文档' }, slug: 'docs/preview' }, ], }, ], |
