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: 🐛 修復 Hexo 主題下 404 頁面無法在地化 #3222

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

noeFly
Copy link
Contributor

@noeFly noeFly commented Feb 11, 2025

註記

  • 此 PR 僅修復 Hexo 主題下的錯誤。
  • 因不確定翻譯須放在哪一類,因此名稱(NOT_FOUND)與類別(COMMON)為臨時起的,還請原作者再做修改。

已知問題

  1. 多语言部分的404文案没有统一且是写死的 #3157
    • 無法使用 /lib/lang 下的語言檔翻譯

解決方案

  1. 修改 /theme/hexo/index.js 程式碼
    • 新增翻譯鍵 COMMON.NOT_FOUND
    • 使用 const { locale } = useGlobal() 導入在地化翻譯
    • 使用 locale.COMMON.NOT_FOUND 提取在地化翻譯

改動收益

  1. 使 404 頁面顯示文字可以套用在地化翻譯

具體改動

  1. themes/hexo/index.js
# themes/hexo/index.js L333
+ const { locale } = useGlobal()

# themes/hexo/index.js L355
- <h2 className='m-0 p-0'>页面未找到</h2>
+ <h2 className='m-0 p-0'>{locale.COMMON.NOT_FOUND}</h2>

測試確認

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

Copy link

vercel bot commented Feb 11, 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.

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