Skip to content
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

fix: 🐛 修復 i18n 無法套用語言變體 #3223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

noeFly
Copy link
Contributor

@noeFly noeFly commented Feb 12, 2025

修復 i18n 無法正確使用語言變體,轉而使用最靠近的語系翻譯

已知問題

  1. 翻譯錯誤套用語言
    • zh-HKzh-TW 下的語言會被錯誤套用 zh-CN
    • 其他語言變體亦可能有此情形

解決方案

  1. 修改 Next.js i18n 的路由設定
  2. 修改套用語言時偵測語言變體的方式

改動收益

  1. 使頁面翻譯正確套用

具體改動

  1. next.config.js
  • 從 config 檔中抓取完整且正確的語言設定
  1. /lib/global.js
  • 移除「將語言暫存到本地儲存空間」功能
  1. /lib/lang.js
  • 移除「將語言暫存到本地儲存空間」功能(saveLangToLocalStorage
  • 移除「從本地儲存空間提取語言」功能(loadLangFromLocalStorage
  • 新增「從 Next.js 路由提取語言」功能(getCurrentLang
  1. /lib/notion/convertInnerUrls.js

測試確認

  • 本地開發環境測試通過
  • 生產環境構建測試通過
  • 版本號正確顯示
  • 環境變數配置正常工作

修復 i18n 無法正確使用語言變體,轉而使用最靠近的語系翻譯
Copy link

vercel bot commented Feb 12, 2025

@noeFly is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

noeFly added a commit to nhush-hg/NHUHG-Next that referenced this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant