-
-
Notifications
You must be signed in to change notification settings - Fork 143
feat: Split zh locale into zh-CN and zh-TW #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
This change refactors the i18n logic to support separate Simplified and Traditional Chinese language variants. Previously, a single 'zh' locale was used for both. - Adds new 'zh-CN' and 'zh-TW' language codes. - Updates all relevant components and data sources to use the new codes. - Ensures proper display of Simplified and Traditional Chinese based on user's browser settings.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough中国語のローカライズと言語コードの扱いが「zh」(中国語)から「zh-CN」(簡体字中国語)と「zh-TW」(繁体字中国語)に細分化されました。これに伴い、関連する設定、ドキュメント、ローカライズファイル、コードロジックが全体的に更新・追加されています。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant i18n
participant LocaleFiles
User->>UI: 言語選択ドロップダウンを開く
UI->>i18n: 利用可能言語リストを取得
i18n->>LocaleFiles: zh-CN/zh-TW/他 言語ファイルを参照
UI->>User: 「简体中文」「繁體中文」などの選択肢を表示
User->>UI: 言語を選択(例: zh-TW)
UI->>i18n: 言語設定をzh-TWに変更
i18n->>LocaleFiles: zh-TW/translation.jsonをロード
UI->>User: UIを繁体字中国語で再描画
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15分 Possibly related PRs
Suggested labels
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (5)
docs/logo_licence_zh-TW.md (1)
24-27: 表現のタイポと思われる箇所
Line 26 の「現狀有姿」は慣用句としては不自然で、通常は「現狀之下」または「現況のまま」を用いることが多いです。微修正をご検討ください。docs/README_zh-CN.md (1)
42-45: 言語リンクの区切り文字に一貫性を末尾の
|(縦棒)が隣接リンクと統一されているか確認してください。将来的にマークダウン自動整形ツールを導入する場合、余分な全角区切り文字が差分ノイズになる恐れがあります。docs/README_en.md (1)
41-43: バックリンク漏れに注意
README_en.mdからはREADME_ko.mdなど他言語へのリンクがありますが、README_zh-TW.md内でも英語版への逆リンクが追加されているか確認してください。相互リンクが欠けるとユーザー遷移が片方向になります。docs/README_zh-TW.md (2)
3-3:<img>タグに alt 属性が欠落しています
画像に代替テキストが無いため、アクセシビリティ lint (MD045) に抵触します。-<img style="max-width: 100%;" src="../public/ogp.png"> +<img style="max-width: 100%;" src="../public/ogp.png" alt="AITuberKit OGP">
35-36: ドキュメントサイト URL が旧zhのままです
ロケール分割後はzh-TWに合わせた URL へ更新した方が一貫性があります。-https://docs.aituberkit.com/zh/ +https://docs.aituberkit.com/zh-TW/これらのパスが既にリダイレクト対応済みであれば無視して構いません。
Also applies to: 54-55, 159-160
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (21)
.env.example(1 hunks)CLAUDE.md(1 hunks)README.md(1 hunks)docs/README_en.md(1 hunks)docs/README_ko.md(1 hunks)docs/README_pl.md(1 hunks)docs/README_zh-CN.md(2 hunks)docs/README_zh-TW.md(1 hunks)docs/auto_translate.md(2 hunks)docs/character_model_licence_zh-TW.md(1 hunks)docs/logo_licence_zh-TW.md(1 hunks)locales/zh-TW/translation.json(1 hunks)scripts/auto_translate.py(1 hunks)src/components/settings/based.tsx(1 hunks)src/features/constants/settings.ts(2 hunks)src/features/messages/synthesizeVoiceGoogle.ts(2 hunks)src/lib/i18n.js(1 hunks)src/pages/_app.tsx(1 hunks)src/pages/api/convertSlide.ts(1 hunks)src/pages/api/stylebertvits2.ts(1 hunks)src/utils/voiceLanguage.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.env.example
📄 CodeRabbit Inference Engine (CLAUDE.md)
設定画面の項目を追加・更新した場合は、必要に応じて新しい環境変数を
.env.exampleの適切な項目に追加してください。
Files:
.env.example
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to locales/{en,ko,zh}/** : 他の言語ファイル(en、ko、zh等)は手動で更新しない
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to locales/ja/** : 言語ファイルの更新は日本語(`/locales/ja/`)のみ行う
📚 Learning: applies to locales/{en,ko,zh}/** : 他の言語ファイル(en、ko、zh等)は手動で更新しない...
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to locales/{en,ko,zh}/** : 他の言語ファイル(en、ko、zh等)は手動で更新しない
Applied to files:
docs/README_zh-CN.mdREADME.md.env.exampleCLAUDE.mdsrc/features/constants/settings.tssrc/pages/api/stylebertvits2.tsdocs/README_pl.mddocs/auto_translate.mdscripts/auto_translate.pydocs/README_en.mddocs/README_ko.mdsrc/pages/_app.tsxsrc/components/settings/based.tsxsrc/lib/i18n.jslocales/zh-TW/translation.json
📚 Learning: applies to .env.example : 設定画面の項目を追加・更新した場合は、必要に応じて新しい環境変数を`.env.example`の適切な項目に追加してください。...
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to .env.example : 設定画面の項目を追加・更新した場合は、必要に応じて新しい環境変数を`.env.example`の適切な項目に追加してください。
Applied to files:
.env.exampleCLAUDE.mddocs/auto_translate.md
📚 Learning: applies to locales/ja/** : 言語ファイルの更新は日本語(`/locales/ja/`)のみ行う...
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to locales/ja/** : 言語ファイルの更新は日本語(`/locales/ja/`)のみ行う
Applied to files:
.env.exampleCLAUDE.mddocs/auto_translate.mddocs/README_ko.mdsrc/lib/i18n.js
📚 Learning: applies to **/__tests__/** : テストは`__tests__`ディレクトリに配置...
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to **/__tests__/** : テストは`__tests__`ディレクトリに配置
Applied to files:
CLAUDE.md
📚 Learning: in `src/components/messageinputcontainer.tsx`, the `if (true) { //isnewuser` condition in the `onuse...
Learnt from: RimgO
PR: tegnike/aituber-kit#395
File: src/components/messageInputContainer.tsx:46-60
Timestamp: 2025-05-21T14:11:19.604Z
Learning: In `src/components/messageInputContainer.tsx`, the `if (true) { //isNewUser` condition in the `onUserDetected` handler is intentionally left as is because this section is planned to be changed later.
Applied to files:
src/pages/_app.tsx
🪛 LanguageTool
docs/README_zh-TW.md
[uncategorized] ~125-~125: 您的意思是“"不"驟”?
Context: ... Node.js: ^20.0.0 - npm: ^10.0.0 ### 安裝步驟 1. 將倉庫克隆到本地。 ```bash git clone http...
(BU)
[uncategorized] ~304-~304: 您的意思是“"不"驟”?
Context: ...題時,包含以下資訊將有助於我們順利響應: - 問題或新功能的詳細描述 - 重現步驟(對於錯誤) - 預期行為與實際行為 - 使用環境(瀏覽器、作業系統、Node...
(BU)
🪛 markdownlint-cli2 (0.17.2)
docs/README_zh-TW.md
3-3: Images should have alternate text (alt text)
(MD045, no-alt-text)
347-347: Bare URL used
(MD034, no-bare-urls)
🔇 Additional comments (18)
.env.example (1)
9-12: 中国語コードの分割反映を確認しました
コメント文にzh-CN/zh-TWが追記されており、実装変更と整合しています。新しい環境変数の追加はなく.env.exampleのガイドラインにも抵触しません。README.md (1)
40-44: リンク分割の実装 OK
简体中文/繁體中文へのリンク追加は i18n 分割方針と一致しており、他言語リンクとの整合も取れています。scripts/auto_translate.py (1)
38-42: 新ディレクトリの存在を確認してください
TARGET_LANGUAGESにzh-CNとzh-TWを追加したことで、スクリプトは
locales/zh-CN/translation.jsonとlocales/zh-TW/translation.jsonを読み書きします。リポジトリに両方のディレクトリが存在しない場合は実行時に失敗します。必要に応じて空の
translation.jsonを追加しておくか、スクリプト側でディレクトリ自動生成を行うと安全です。docs/README_pl.md (1)
42-44: リンク先ファイルの存在確認を推奨
README_zh-CN.mdとREADME_zh-TW.mdへのリンクに更新されていますが、同じdocs/配下に実際のファイルが存在するか CI で検証することを推奨します。存在しない場合、GitHub 上の 404 となります。docs/README_zh-CN.md (1)
334-335: パス名の-zh-CN付与は OKライセンス関連ページのパスを
*_zh-CN.mdに変更した点は、zh-TWとの切り分けとして妥当です。docs/README_ko.md (1)
42-44: リンク更新は妥当ですがファイル配置を要確認韓国語 README でも中国語を 2 バリアントへ分割した点は問題ありません。念のため CI でリンク切れチェックを行うことを推奨します。
src/components/settings/based.tsx (1)
158-159: 中国語のロケール分離が正しく実装されています簡体字中国語(zh-CN)と繁体字中国語(zh-TW)の選択肢が適切に分離されており、既存の言語切り替えロジックとも整合性が取れています。
CLAUDE.md (1)
78-78: ドキュメントが新しい中国語ロケールコードに適切に更新されていますzh-CN、zh-TWの明示的な記載により、言語ファイル更新ルールがより明確になっています。
docs/auto_translate.md (1)
43-43: 自動翻訳ドキュメントが新しい中国語ロケールに正しく更新されています対象言語の説明とコード例の両方で、zh-CNとzh-TWが明示的に記載され、自動翻訳機能の対象言語が正確に反映されています。
Also applies to: 80-80
src/lib/i18n.js (1)
12-17: 中国語ロケール設定と翻訳ファイル存在確認zh-CNおよびzh-TWの
translation.jsonがlocales/zh-CN/とlocales/zh-TW/に正しく存在しており、i18n設定も他のロケールと同様の構造で実装されています。問題ありませんので承認します。src/utils/voiceLanguage.ts (1)
12-15: 音声言語コードマッピングが中国語ロケール分離に正しく対応していますzh-CNとzh-TWのケースが個別に処理されることで、音声合成で適切な言語コードが使用されます。
src/pages/_app.tsx (1)
29-34: 言語検出ロジックが適切に実装されています繁体字中国語(zh-TW)と簡体字中国語(zh-CN)の判定ロジックが正しく実装されています。ブラウザ言語が「zh-TW」の場合はそのまま保持し、その他の「zh」系統は「zh-CN」にマッピングする処理が適切です。
src/features/constants/settings.ts (2)
107-108: 言語定数の更新が適切です中国語言語コードを「zh」から「zh-CN」(簡体字中国語)と「zh-TW」(繁体字中国語)に分割した処理が正しく実装されています。
129-130: 音声言語タイプの更新が一貫していますVoiceLanguageタイプでの中国語バリアント対応が、LANGUAGESの更新と一貫性を保って実装されています。
src/features/messages/synthesizeVoiceGoogle.ts (2)
68-71: Google TTS音声タイプのマッピングが正確です中国語バリアントに対するGoogle TTSの音声タイプマッピングが適切に実装されています。「zh-CN」は「cmn-CN-Standard-A」、「zh-TW」は「cmn-TW-Standard-A」に正しくマッピングされています。
107-110: 音声言語コードの変換が一貫していますgetVoiceLanguageCode関数での中国語バリアント処理が、getGoogleTtsType関数と一貫性を保って実装されています。
locales/zh-TW/translation.json (1)
1-446: 新しい繁体字中国語翻訳ファイルが追加されました従来の学習結果に基づき、日本語以外の言語ファイルは手動でレビューしません。このファイルはアプリケーションの繁体字中国語対応のために適切に追加されているようです。
docs/character_model_licence_zh-TW.md (1)
1-69: 繁体字中国語のモデル使用条項ドキュメントが適切に追加されましたVRMおよびLive2Dモデルの使用条項について、繁体字中国語での包括的なドキュメントが追加されています。著作権、使用許可・禁止事項、免責事項が明確に記載されており、多言語対応の一環として適切な追加です。
| case 'zh-CN': | ||
| return 'Simplified Chinese' | ||
| case 'zh-TW': | ||
| return 'Traditional Chinese' | ||
| case 'ko': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
'zh' エイリアスを残さないと後方互換が切れる恐れ
フロント側や外部 API から "zh" が送られて来た場合、現在の実装だと default ルートに落ちて "Japanese" が返ります。旧バージョンとの互換性を保つなら、簡体字へフォールバックさせる案を推奨します。
case 'zh-CN':
return 'Simplified Chinese'
case 'zh-TW':
return 'Traditional Chinese'
+ case 'zh': // backward compatibility
+ return 'Simplified Chinese'以下のコマンドで src/pages/api/convertSlide.ts 内に case 'zh' が定義されているか確認しましょう。
🏁 Script executed:
#!/bin/bash
rg -n "case 'zh" src/pages/api/convertSlide.tsLength of output: 95
更に前後のデフォルト処理を確認します。
🏁 Script executed:
#!/bin/bash
sed -n '300,380p' src/pages/api/convertSlide.tsLength of output: 2136
Case 'zh' のエイリアスを追加して後方互換性を保つ
getLanguage 関数に case 'zh' がないため、フロントや外部 API から "zh" が渡ってきた際に意図しないデフォルト(日本語)へ落ちてしまいます。簡体字(Simplified Chinese)へフォールバックするよう、以下の変更をお願いします。
- ファイル:
src/pages/api/convertSlide.ts - 関数:
getLanguage - 該当箇所:
case 'zh-TW'の直後
case 'zh-TW':
return 'Traditional Chinese'
+ case 'zh': // backward compatibility
+ return 'Simplified Chinese'
case 'ko':
return 'Korean'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case 'zh-CN': | |
| return 'Simplified Chinese' | |
| case 'zh-TW': | |
| return 'Traditional Chinese' | |
| case 'ko': | |
| case 'zh-CN': | |
| return 'Simplified Chinese' | |
| case 'zh-TW': | |
| return 'Traditional Chinese' | |
| case 'zh': // backward compatibility | |
| return 'Simplified Chinese' | |
| case 'ko': | |
| return 'Korean' |
🤖 Prompt for AI Agents
In src/pages/api/convertSlide.ts around lines 358 to 362, the getLanguage
function lacks a case for 'zh', causing inputs of 'zh' to default incorrectly to
Japanese. Add a new case 'zh' immediately after the 'case 'zh-TW':' line that
returns 'Simplified Chinese' to maintain backward compatibility and ensure
correct language mapping.
| case 'zh-CN': | ||
| case 'zh-TW': | ||
| return 'ZH' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レガシー値 zh を受け付けず互換性が失われる
以前に zh を送っていたクライアントが 500 を返される恐れがあります。後方互換のため case 'zh': も残すか、default を ZH に変えて回避してください。
case 'en':
return 'EN'
+ case 'zh':
case 'zh-CN':
case 'zh-TW':
return 'ZH'
- default:
- return 'EN'
+ default:
+ return 'EN'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case 'zh-CN': | |
| case 'zh-TW': | |
| return 'ZH' | |
| case 'en': | |
| return 'EN' | |
| case 'zh': | |
| case 'zh-CN': | |
| case 'zh-TW': | |
| return 'ZH' | |
| default: | |
| return 'EN' |
🤖 Prompt for AI Agents
In src/pages/api/stylebertvits2.ts around lines 14 to 16, the switch statement
no longer handles the legacy value 'zh', which may cause clients sending 'zh' to
receive a 500 error. To fix this, add a case for 'zh' alongside 'zh-CN' and
'zh-TW' to return 'ZH', or alternatively change the default case to return 'ZH'
to maintain backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/README_zh-TW.md (1)
33-37: 文檔網站リンクが簡体字用 URL のままです
現在https://docs.aituberkit.com/zh/を指していますが、繁体字ページが存在する場合は/zh-TW/など繁体字向け URL へ変更してください。検索エンジンや UA 言語設定による自動切り替えを行っていない場合、利用者が簡体字サイトへ遷移してしまいます。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/README_zh-CN.md(2 hunks)docs/README_zh-TW.md(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/README_zh-CN.md
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to locales/{en,ko,zh}/** : 他の言語ファイル(en、ko、zh等)は手動で更新しない
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to locales/ja/** : 言語ファイルの更新は日本語(`/locales/ja/`)のみ行う
📚 Learning: applies to locales/ja/** : 言語ファイルの更新は日本語(`/locales/ja/`)のみ行う...
Learnt from: CR
PR: tegnike/aituber-kit#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-24T14:51:36.976Z
Learning: Applies to locales/ja/** : 言語ファイルの更新は日本語(`/locales/ja/`)のみ行う
Applied to files:
docs/README_zh-TW.md
🪛 LanguageTool
docs/README_zh-TW.md
[uncategorized] ~125-~125: 您的意思是“"不"驟”?
Context: ... Node.js: ^20.0.0 - npm: ^10.0.0 ### 安裝步驟 1. 將倉庫克隆到本地。 ```bash git clone http...
(BU)
[uncategorized] ~304-~304: 您的意思是“"不"驟”?
Context: ...題時,包含以下資訊將有助於我們順利響應: - 問題或新功能的詳細描述 - 重現步驟(對於錯誤) - 預期行為與實際行為 - 使用環境(瀏覽器、作業系統、Node...
(BU)
🔇 Additional comments (1)
docs/README_zh-TW.md (1)
39-44: Polski README へのパス重複問題が解消されています
過去に指摘のあったdocs/二重指定が修正され、相対パスが正しくなりました。
This change refactors the i18n logic to support separate Simplified and Traditional Chinese language variants. Previously, a single 'zh' locale was used for both.
PS. The documentation website is also recommended to distinguish between zh-CN and zh-TW, which might be more user-friendly for regions using Traditional Chinese.
Summary by CodeRabbit
新機能
ドキュメント
バグ修正