Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/actions/update-search-index/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ inputs:
locale:
description: "Locale to update (e.g., 'en' or 'zh-hans')"
required: true
orama_private_api_key_en:
description: "Orama Private API Key for EN"
required: true
orama_private_api_key_zh_hans:
description: "Orama Private API Key for ZH-HANS"
orama_private_api_key:
description: "Orama Private API Key"
required: true
runs:
using: "composite"
Expand All @@ -26,5 +23,4 @@ runs:
run: pnpm run update-search-index
env:
LOCALE: "${{ inputs.locale }}"
ORAMA_PRIVATE_API_KEY_EN: ${{ inputs.orama_private_api_key_en }}
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ inputs.orama_private_api_key_zh_hans }}
ORAMA_PRIVATE_API_KEY: ${{ inputs.orama_private_api_key }}
8 changes: 8 additions & 0 deletions .github/actions/vercel-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ runs:
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
shell: bash
- name: Echo Vercel Environment File
run: |
ls -l .vercel/.env*
for f in .vercel/.env*; do
echo "\n----- $f -----"
cat "$f"
done
shell: bash
- name: Build Project Artifacts
run: npx vercel build ${{ inputs.prodFlag }} --token=${{ inputs.vercel_token }}
env:
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
strategy:
matrix:
include:
- name: Deploy EN
locale: EN
- locale: en
secret_project_id: VERCEL_PROJECT_EN_ID
- name: Deploy ZH-HANS
locale: ZH-HANS
- locale: zh-hans
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
name: ${{ matrix.name }}
- locale: zh-hant
secret_project_id: VERCEL_PROJECT_ZH_HANT_ID
name: Deploy ${{ matrix.locale }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -38,7 +38,6 @@ jobs:
uses: ./.github/actions/vercel-deploy
with:
environment: preview
prodFlag: ""
vercel_project_id: ${{ secrets[matrix.secret_project_id] }}
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }}
vercel_token: ${{ secrets.VERCEL_TOKEN }}
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ jobs:
strategy:
matrix:
include:
- name: Deploy EN
locale: en
- locale: en
secret_project_id: VERCEL_PROJECT_EN_ID
- name: Deploy ZH-HANS
locale: zh-hans
orama_private_api_key: ORAMA_PRIVATE_API_KEY_EN
- locale: zh-hans
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
name: ${{ matrix.name }}
orama_private_api_key: ORAMA_PRIVATE_API_KEY_ZH_HANS
- locale: zh-hant
secret_project_id: VERCEL_PROJECT_ZH_HANT_ID
orama_private_api_key: ORAMA_PRIVATE_API_KEY_ZH_HANT
name: Deploy ${{ matrix.locale }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -39,5 +42,4 @@ jobs:
uses: ./.github/actions/update-search-index
with:
locale: ${{ matrix.locale }}
orama_private_api_key_en: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
orama_private_api_key_zh_hans: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}
orama_private_api_key: ${{ secrets[matrix.orama_private_api_key] }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pnpm dev
This project includes a custom translation utility that can translate the Next.js documentation into multiple languages. Currently, it supports:

- English (source)
- Simplified Chinese (zh-Hans)
- Simplified Chinese (zh-hans)
- More languages can be added in the translation configuration

Documentation content is stored in the `apps/docs/content` directory:
Expand Down
97 changes: 97 additions & 0 deletions apps/docs/messages/zh-hant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"baseOptions": {
"title": "Next.js 繁體中文",
"doc": "文件"
},
"meta": {
"title": "Next.js - 繁體中文",
"description": "生產級 React 應用,具備卓越擴展能力。全球領先企業都在用 Next.js by Vercel 構建靜態和動態網站及 Web 應用。"
},
"sidebar": {
"app": {
"title": "使用 App 路由器",
"description": "/app 中可用的功能"
},
"pages": {
"title": "使用 Pages 路由器",
"description": "/pages 中可用的功能"
},
"version": {
"latest": {
"title": "使用最新版本"
},
"v14": {
"title": "使用 14 版"
},
"v13": {
"title": "使用 13 版"
}
}
},
"HomePage": {
"title": "React 框架,面向 Web",
"subtitle": "被全球領先企業採用,Next.js 讓你可以用 React 元件的力量構建 <strong>高品質 Web 應用</strong>。",
"getStarted": "快速開始",
"learn": "學習 Next.js",
"copyCommand": "▲ ~ npx create-next-app@latest",
"featuresTitle": "Next.js 有什麼?",
"featuresSubtitle": "構建卓越 Web 產品所需的一切。",
"features": [
{
"title": "內建最佳化",
"desc": "自動圖片、字型和腳本最佳化,提升用戶體驗和核心 Web 指標。",
"href": "/docs/app/building-your-application/optimizing/images"
},
{
"title": "資料獲取",
"desc": "讓你的 React 元件支援 async/await。Next.js 支援伺服器端和客戶端資料獲取。",
"href": "/docs/app/building-your-application/data-fetching"
},
{
"title": "伺服器端操作",
"desc": "透過呼叫函式直接執行伺服器端程式碼,無需 API。輕鬆重新驗證快取並在一次網路往返中更新 UI。",
"href": "/docs/app/building-your-application/data-fetching/forms-and-mutations"
},
{
"title": "進階路由與巢狀路由",
"desc": "透過檔案系統建立路由,支援更進階的路由模式和 UI 佈局。",
"href": "/docs/app/building-your-application/routing"
},
{
"title": "動態 HTML 串流渲染",
"desc": "從伺服器即時串流渲染 UI,整合 App Router 和 React Suspense。",
"href": "/docs/app/building-your-application/routing/loading-ui-and-streaming"
},
{
"title": "CSS 支援",
"desc": "用你喜歡的工具為應用添加樣式,支援 CSS Modules、Tailwind CSS 及主流社群庫。",
"href": "/docs/app/building-your-application/styling"
},
{
"title": "路由處理器",
"desc": "構建 API 端點,安全連接第三方服務,處理認證或監聽 Webhook。",
"href": "/docs/app/building-your-application/routing/router-handlers"
},
{
"title": "中介軟體",
"desc": "靈活控制請求入口。用程式碼定義路由和存取規則,實現認證、實驗和國際化。",
"href": "/docs/app/building-your-application/routing/middleware"
},
{
"title": "React 伺服器端元件",
"desc": "無需傳送額外客戶端 JS 即可添加元件,基於最新 React 特性。",
"href": "/docs/app/building-your-application/rendering/server-components"
},
{
"title": "客戶端與伺服器端渲染",
"desc": "靈活的渲染與快取選項,包括每頁級別的 ISR(增量靜態再生)。",
"href": "/docs/app/building-your-application/rendering"
},
{
"title": "Next.js 15",
"desc": "全端能力賦能前端。閱讀發佈說明。",
"href": "/blog/next-15"
}
]
}
}
13 changes: 10 additions & 3 deletions apps/docs/scripts/update-orama-index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ import type { Locale } from 'next-intl';
import { sync } from '../src/lib/orama/orama-cloud';

export async function updateSearchIndexes(): Promise<void> {
const { locale, privateKey, index } =
ORAMA_CONFIGS_MAP[process.env.LOCALE as Locale];
if (!process.env.ORAMA_PRIVATE_API_KEY) {
console.warn(
'ORAMA_PRIVATE_API_KEY is not set. Skipping Orama index update.',
);
return;
}
const { locale, index } = ORAMA_CONFIGS_MAP[process.env.LOCALE as Locale];

const manager = new CloudManager({ api_key: privateKey });
const manager = new CloudManager({
api_key: process.env.ORAMA_PRIVATE_API_KEY || '',
});
// Get all .body files in the static directory
const staticDir = path.join('.next/server/app/static');
let allRecords: OramaDocument[] = [];
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/scripts/update-search-index.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import env from '@next/env';
env.loadEnvConfig(process.cwd());

console.log(process.env);

import { updateSearchIndexes } from './update-orama-index.mjs';

async function main() {
Expand Down
10 changes: 8 additions & 2 deletions apps/docs/src/lib/orama/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Locale } from 'next-intl';

const ORAMA_EN_CONFIG = {
locale: 'en',
privateKey: process.env.ORAMA_PRIVATE_API_KEY_EN || '',
apiKey: '4DujbZrvGuklBRFcZBtegX3fV1lzNXnU',
index: 'vuywlowcbl1w3s2jtvq5ysxl',
endpoint: 'https://cloud.orama.run/v1/indexes/en-ai00ky',
Expand All @@ -12,15 +11,22 @@ type ORAMA_EN_CONFIG = typeof ORAMA_EN_CONFIG;

const OORAMA_ZH_HANS_CONFIG = {
locale: 'zh-hans',
privateKey: process.env.ORAMA_PRIVATE_API_KEY_ZH_HANS || '',
apiKey: '6nEUS4tyXiajWxZ8qMEQMzzLoOYTuLSk',
index: 'vcwl00bwd64h3pa8yq8x107y',
endpoint: 'https://cloud.orama.run/v1/indexes/zh-hans-js5ujm',
};

const OORAMA_ZH_HANT_CONFIG = {
locale: 'zh-hant',
apiKey: 'm2Wdhf6R37fKAhXNDufzbegTuQdz6aqf',
index: 'l4wtdj6zo3gpv432pmf4s98g',
endpoint: 'https://cloud.orama.run/v1/indexes/zh-hant-nvys3a',
};

export const ORAMA_CONFIGS = [ORAMA_EN_CONFIG, OORAMA_ZH_HANS_CONFIG] as const;

export const ORAMA_CONFIGS_MAP: Record<Locale, ORAMA_EN_CONFIG> = {
en: ORAMA_EN_CONFIG,
'zh-hans': OORAMA_ZH_HANS_CONFIG,
'zh-hant': OORAMA_ZH_HANT_CONFIG,
} as const;
28 changes: 14 additions & 14 deletions apps/docs/translation.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
langs: {
'zh-Hans': {
'zh-hans': {
name: 'Simplified Chinese',
// 翻译规则和指南
guide: `
Expand All @@ -13,19 +13,19 @@ export default {
// 格式: 'English term': '中文翻译'
terms: {},
},
// 'zh-Hant': {
// name: 'Traditional Chinese',
// // 翻譯規則和指南
// guide: `
// - For technical terms that should not be fully translated, use the format: "繁體中文翻譯 (English term)"
// Example: "伺服器渲染 (SSR)" instead of just "SSR" or just "伺服器渲染"
// - Add a space between Chinese characters and English words/symbols to improve readability
// - Maintain consistent translations for common terms across the entire document
// `,
// // 常見技術術語翻譯詞典
// // 格式: 'English term': '繁體中文翻譯'
// terms: {},
// },
'zh-hant': {
name: 'Traditional Chinese',
// 翻譯規則和指南
guide: `
- For technical terms that should not be fully translated, use the format: "繁體中文翻譯 (English term)"
Example: "伺服器渲染 (SSR)" instead of just "SSR" or just "伺服器渲染"
- Add a space between Chinese characters and English words/symbols to improve readability
- Maintain consistent translations for common terms across the entire document
`,
// 常見技術術語翻譯詞典
// 格式: 'English term': '繁體中文翻譯'
terms: {},
},
// ja: {
// name: 'Japanese',
// guide: `
Expand Down