Skip to content

Commit b435c1c

Browse files
committed
feat: update zh-hant
1 parent 2efed8a commit b435c1c

File tree

9 files changed

+60
-40
lines changed

9 files changed

+60
-40
lines changed

.github/actions/update-search-index/action.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ inputs:
44
locale:
55
description: "Locale to update (e.g., 'en' or 'zh-hans')"
66
required: true
7-
orama_private_api_key_en:
8-
description: "Orama Private API Key for EN"
9-
required: true
10-
orama_private_api_key_zh_hans:
11-
description: "Orama Private API Key for ZH-HANS"
7+
orama_private_api_key:
8+
description: "Orama Private API Key"
129
required: true
1310
runs:
1411
using: "composite"
@@ -26,5 +23,4 @@ runs:
2623
run: pnpm run update-search-index
2724
env:
2825
LOCALE: "${{ inputs.locale }}"
29-
ORAMA_PRIVATE_API_KEY_EN: ${{ inputs.orama_private_api_key_en }}
30-
ORAMA_PRIVATE_API_KEY_ZH_HANS: ${{ inputs.orama_private_api_key_zh_hans }}
26+
ORAMA_PRIVATE_API_KEY: ${{ inputs.orama_private_api_key }}

.github/actions/vercel-deploy/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ runs:
3030
VERCEL_PROJECT_ID: ${{ inputs.vercel_project_id }}
3131
VERCEL_ORG_ID: ${{ inputs.vercel_org_id }}
3232
shell: bash
33+
- name: Echo Vercel Environment File
34+
run: |
35+
ls -l .vercel/.env*
36+
for f in .vercel/.env*; do
37+
echo "\n----- $f -----"
38+
cat "$f"
39+
done
40+
shell: bash
3341
- name: Build Project Artifacts
3442
run: npx vercel build ${{ inputs.prodFlag }} --token=${{ inputs.vercel_token }}
3543
env:

.github/workflows/prerelease.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
strategy:
2020
matrix:
2121
include:
22-
- name: Deploy EN
23-
locale: EN
22+
- locale: en
2423
secret_project_id: VERCEL_PROJECT_EN_ID
25-
- name: Deploy ZH-HANS
26-
locale: ZH-HANS
24+
- locale: zh-hans
2725
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
28-
name: ${{ matrix.name }}
26+
- locale: zh-hant
27+
secret_project_id: VERCEL_PROJECT_ZH_HANT_ID
28+
name: Deploy ${{ matrix.locale }}
2929
steps:
3030
- name: Checkout code
3131
uses: actions/checkout@v3
@@ -38,7 +38,6 @@ jobs:
3838
uses: ./.github/actions/vercel-deploy
3939
with:
4040
environment: preview
41-
prodFlag: ""
4241
vercel_project_id: ${{ secrets[matrix.secret_project_id] }}
4342
vercel_org_id: ${{ secrets.VERCEL_ORG_ID }}
4443
vercel_token: ${{ secrets.VERCEL_TOKEN }}

.github/workflows/release.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ jobs:
1212
strategy:
1313
matrix:
1414
include:
15-
- name: Deploy EN
16-
locale: en
15+
- locale: en
1716
secret_project_id: VERCEL_PROJECT_EN_ID
18-
- name: Deploy ZH-HANS
19-
locale: zh-hans
17+
orama_private_api_key: ORAMA_PRIVATE_API_KEY_EN
18+
- locale: zh-hans
2019
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
21-
name: ${{ matrix.name }}
20+
orama_private_api_key: ORAMA_PRIVATE_API_KEY_ZH_HANS
21+
- locale: zh-hant
22+
secret_project_id: VERCEL_PROJECT_ZH_HANT_ID
23+
orama_private_api_key: ORAMA_PRIVATE_API_KEY_ZH_HANT
24+
name: Deploy ${{ matrix.locale }}
2225
steps:
2326
- name: Checkout code
2427
uses: actions/checkout@v3
@@ -39,5 +42,4 @@ jobs:
3942
uses: ./.github/actions/update-search-index
4043
with:
4144
locale: ${{ matrix.locale }}
42-
orama_private_api_key_en: ${{ secrets.ORAMA_PRIVATE_API_KEY_EN }}
43-
orama_private_api_key_zh_hans: ${{ secrets.ORAMA_PRIVATE_API_KEY_ZH_HANS }}
45+
orama_private_api_key: ${{ secrets[matrix.orama_private_api_key] }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pnpm dev
4747
This project includes a custom translation utility that can translate the Next.js documentation into multiple languages. Currently, it supports:
4848

4949
- English (source)
50-
- Simplified Chinese (zh-Hans)
50+
- Simplified Chinese (zh-hans)
5151
- More languages can be added in the translation configuration
5252

5353
Documentation content is stored in the `apps/docs/content` directory:

apps/docs/scripts/update-orama-index.mts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ import type { Locale } from 'next-intl';
77
import { sync } from '../src/lib/orama/orama-cloud';
88

99
export async function updateSearchIndexes(): Promise<void> {
10-
const { locale, privateKey, index } =
11-
ORAMA_CONFIGS_MAP[process.env.LOCALE as Locale];
10+
if (!process.env.ORAMA_PRIVATE_API_KEY) {
11+
console.warn(
12+
'ORAMA_PRIVATE_API_KEY is not set. Skipping Orama index update.',
13+
);
14+
return;
15+
}
16+
const { locale, index } = ORAMA_CONFIGS_MAP[process.env.LOCALE as Locale];
1217

13-
const manager = new CloudManager({ api_key: privateKey });
18+
const manager = new CloudManager({
19+
api_key: process.env.ORAMA_PRIVATE_API_KEY || '',
20+
});
1421
// Get all .body files in the static directory
1522
const staticDir = path.join('.next/server/app/static');
1623
let allRecords: OramaDocument[] = [];

apps/docs/scripts/update-search-index.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import env from '@next/env';
22
env.loadEnvConfig(process.cwd());
33

4+
console.log(process.env);
5+
46
import { updateSearchIndexes } from './update-orama-index.mjs';
57

68
async function main() {

apps/docs/src/lib/orama/config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Locale } from 'next-intl';
22

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

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

19+
const OORAMA_ZH_HANT_CONFIG = {
20+
locale: 'zh-hant',
21+
apiKey: 'm2Wdhf6R37fKAhXNDufzbegTuQdz6aqf',
22+
index: 'l4wtdj6zo3gpv432pmf4s98g',
23+
endpoint: 'https://cloud.orama.run/v1/indexes/zh-hant-nvys3a',
24+
};
25+
2126
export const ORAMA_CONFIGS = [ORAMA_EN_CONFIG, OORAMA_ZH_HANS_CONFIG] as const;
2227

2328
export const ORAMA_CONFIGS_MAP: Record<Locale, ORAMA_EN_CONFIG> = {
2429
en: ORAMA_EN_CONFIG,
2530
'zh-hans': OORAMA_ZH_HANS_CONFIG,
31+
'zh-hant': OORAMA_ZH_HANT_CONFIG,
2632
} as const;

apps/docs/translation.config.mjs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
langs: {
3-
'zh-Hans': {
3+
'zh-hans': {
44
name: 'Simplified Chinese',
55
// 翻译规则和指南
66
guide: `
@@ -13,19 +13,19 @@ export default {
1313
// 格式: 'English term': '中文翻译'
1414
terms: {},
1515
},
16-
// 'zh-Hant': {
17-
// name: 'Traditional Chinese',
18-
// // 翻譯規則和指南
19-
// guide: `
20-
// - For technical terms that should not be fully translated, use the format: "繁體中文翻譯 (English term)"
21-
// Example: "伺服器渲染 (SSR)" instead of just "SSR" or just "伺服器渲染"
22-
// - Add a space between Chinese characters and English words/symbols to improve readability
23-
// - Maintain consistent translations for common terms across the entire document
24-
// `,
25-
// // 常見技術術語翻譯詞典
26-
// // 格式: 'English term': '繁體中文翻譯'
27-
// terms: {},
28-
// },
16+
'zh-hant': {
17+
name: 'Traditional Chinese',
18+
// 翻譯規則和指南
19+
guide: `
20+
- For technical terms that should not be fully translated, use the format: "繁體中文翻譯 (English term)"
21+
Example: "伺服器渲染 (SSR)" instead of just "SSR" or just "伺服器渲染"
22+
- Add a space between Chinese characters and English words/symbols to improve readability
23+
- Maintain consistent translations for common terms across the entire document
24+
`,
25+
// 常見技術術語翻譯詞典
26+
// 格式: 'English term': '繁體中文翻譯'
27+
terms: {},
28+
},
2929
// ja: {
3030
// name: 'Japanese',
3131
// guide: `

0 commit comments

Comments
 (0)