Skip to content

Add internationalization support for Japanese and English#5

Open
msakai wants to merge 1 commit into
mainfrom
claude/add-multilingual-support-m39nQ
Open

Add internationalization support for Japanese and English#5
msakai wants to merge 1 commit into
mainfrom
claude/add-multilingual-support-m39nQ

Conversation

@msakai
Copy link
Copy Markdown
Owner

@msakai msakai commented Feb 16, 2026

Summary

This PR adds comprehensive internationalization (i18n) support to the game, enabling it to display in both Japanese and English based on user language preferences or URL parameters.

Key Changes

  • New i18n module (js/i18n.js): Created a centralized translation system with message dictionaries for Japanese and English, automatic language detection based on browser language preferences or ?lang= URL parameter, with Japanese as the fallback language
  • Updated UI components: Modified title screen, game over screen, and stage completion screens to use the new t() translation function instead of hardcoded strings
  • Manifest files: Added manifest.en.json for English localization and updated manifest.json to include language metadata
  • HTML integration: Added script in index.html to set document language, update page title, and dynamically load the appropriate manifest file based on detected language
  • Translated strings: All user-facing text now supports both languages including:
    • Game title and instructions
    • Score labels
    • Game state messages (GAME OVER, GAME CLEAR)

Implementation Details

  • Language detection follows a priority order: URL parameter → browser language preferences → Japanese default
  • The translation function gracefully falls back to Japanese if a key is missing in the current language
  • Manifest switching is handled dynamically in the HTML to ensure PWA metadata matches the active language

https://claude.ai/code/session_01QAYkCU7d7Yjvu753eDBMiB

Introduce js/i18n.js that detects locale from ?lang= query parameter
or navigator.languages and provides a t() translation function.
Replace all hardcoded Japanese strings in title.js, gameOver.js,
player.js, and stage.js with t() calls. Dynamically set <html lang>,
<title>, and manifest link based on detected language. Add English
manifest (manifest.en.json).

https://claude.ai/code/session_01QAYkCU7d7Yjvu753eDBMiB
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.

2 participants