Skip to content

feat: implement i18n support and add Japanese localization#9

Open
ariela wants to merge 1 commit intoJoeJoesGit:mainfrom
ariela:features/i18n
Open

feat: implement i18n support and add Japanese localization#9
ariela wants to merge 1 commit intoJoeJoesGit:mainfrom
ariela:features/i18n

Conversation

@ariela
Copy link
Copy Markdown

@ariela ariela commented Feb 5, 2026

This Pull Request introduces a lightweight internationalization (i18n) framework to the Alchemy Factory Calculator, along with full support for the Japanese language. It also includes a significant refactor of the UI logic to support dynamic localization.

Key Changes

  1. I18n Framework (alchemy_i18n.js)
    • Implemented a lightweight translation module that uses English keys as the source.
    • Supports dynamic dictionary loading via script tags to ensure compatibility with the file:// protocol (no CORS issues).
    • Persists language preference in localStorage.
  2. Japanese Localization (lang/ja.js)
    • Added a comprehensive translation dictionary for all items, machines, UI labels, and warning messages.
  3. UI & Tooltip Refactoring
    • Replaced hardcoded strings in alchemy_calc.js and alchemy_ui.js with I18n.t() calls.
    • Refactored tooltip generation logic to be more modular and localization-friendly.
    • Added data-i18n attributes to index.html for static text management.
  4. Multilingual Search & UX Improvements
    • Enhanced the search logic for items and recipes to match both internal English keys and localized display names.
    • Added a language selector in the header for seamless switching without page reloads.
  5. Logistics & Status Localization
    • Localized dynamic labels such as belt load ratios (e.g., Full Belt, ~75% Load) and production status messages.

Technical Notes

  • Fallback Mechanism: The system defaults to the English key if a translation is missing, ensuring no broken UI elements.
  • Extensibility: The architecture is designed to make adding future languages as simple as dropping a new file in the lang/ directory.

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