Skip to content

feat(i18n): Implement multi-language support (en, zh-CN, zh-TW, ja) with auto-detection#66

Open
yozurukt wants to merge 12 commits into
remvze:mainfrom
yozurukt:i18n
Open

feat(i18n): Implement multi-language support (en, zh-CN, zh-TW, ja) with auto-detection#66
yozurukt wants to merge 12 commits into
remvze:mainfrom
yozurukt:i18n

Conversation

@yozurukt

@yozurukt yozurukt commented Apr 20, 2025

Copy link
Copy Markdown

Close #49
This PR adds internationalization (i18n) support to Moodist using i18next and react-i18next, with the UI now available in English, Simplified Chinese, Traditional Chinese, and Japanese.

Key Changes:

  • Multi-language UI: Extracted all visible UI text and accessibility (a11y) strings into separate locale files (en, zh-CN, zh-TW, ja) for easy translation and maintenance.
  • Automatic Language Redirect: Implemented a client-side redirect on / that detects the user's preferred language via navigator.languages, and routes them to the appropriate localized version (uses sessionStorage to prevent redirect loops).
  • CJK Font Support (LXGW WenKai Lite): Integrated LXGW WenKai Lite and applied it conditionally for zh-CN, zh-TW, and ja locales using @font-face and :lang() selectors to enhance readability for CJK characters.
  • Font Size Adjustment for CJK: Slightly increased the base font size for CJK locales via CSS variables for improved visual balance and legibility.
  • Accessibility Improvements: All accessibility strings (e.g., aria-label, alt, etc.) have been internationalized and moved into locale files for consistency.
  • Stylelint Config Fix: Updated Stylelint settings to allow Astro’s :global() pseudo-class, resolving an issue when styling set:html content in the footer.

Note: I'm still new to front-end development, so I’d really appreciate any feedback on the implementation, especially on best practices or things I might have overlooked!

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.

中文汉化 Chinese

1 participant