Skip to content

Add Japanese localization to WebUI#13

Merged
rysb-dev merged 3 commits intomainfrom
localization-ja
Feb 5, 2026
Merged

Add Japanese localization to WebUI#13
rysb-dev merged 3 commits intomainfrom
localization-ja

Conversation

@rysb-dev
Copy link
Copy Markdown
Owner

@rysb-dev rysb-dev commented Feb 5, 2026

Summary

Adds Japanese (日本語) localization support to the Agari WebUI with automatic browser language detection and persistent user preference.

Changes

New i18n System

  • Type-safe translation keys (web/src/lib/i18n/types.ts)
  • English translations (web/src/lib/i18n/en.ts)
  • Japanese translations (web/src/lib/i18n/ja.ts)
  • Locale store with localStorage persistence and browser language detection (web/src/lib/i18n/index.ts)

UI Updates

  • Added LanguageSwitcher component in header
  • Localized all UI strings in App.svelte, ContextOptions.svelte, ScoreResult.svelte, DoraPicker.svelte
  • Yaku names and score levels (満貫, 跳満, etc.) are translated via mapping from WASM backend strings

Accessibility Fixes

  • Fixed label/input associations
  • Added proper ARIA attributes to wind button groups
  • Added tabindex to dialog backdrop

Testing

  • svelte-check: 0 errors, 0 warnings
  • Production build succeeds

- Add i18n module using Svelte stores for reactive locale state
- Create translation files for English (en) and Japanese (ja)
- Add LanguageSwitcher component in header
- Persist user's language preference to localStorage
- Auto-detect browser language on first visit
- Update all UI text in App.svelte, ContextOptions, ScoreResult, and DoraPicker
- Fix a11y warnings (labels without controls, dialog tabindex)

The localization covers:
- Header/footer text
- Hand builder section (melds, tiles, hints)
- Scoring options (win type, winds, riichi, situational yaku)
- Results display (han, fu, yaku, dora, fu breakdown)
- All buttons and labels

Type-safe translations with TypeScript interfaces ensure
maintainability when adding new languages.
- Add translations for all yaku names (riichi, tanyao, pinfu, etc.)
- Add translations for score levels (mangan, haneman, baiman, etc.)
- Create translateYaku() and translateScoreLevel() helper functions
- Update ScoreResult component to use translated values

The yaku names now display in Japanese when Japanese locale is selected:
- 立直, 一発, 断幺九, 平和, etc.

Score levels also display in Japanese:
- 満貫, 跳満, 倍満, 三倍満, 役満, etc.
- Update yakuNameMap keys to match agari-wasm yaku_name() output
- WASM uses shorter names (e.g., 'Sanshoku Doujun') vs CLI's verbose
  names (e.g., 'Sanshoku Doujun (Mixed Triple Sequence)')
- Fix Yakuhai format: 'Yakuhai (East)' instead of 'Yakuhai: East Wind'
- Make translateYaku/translateScoreLevel reactive by passing $t param
- Export yakuNameMap and scoreLevelMap for component use
@rysb-dev rysb-dev self-assigned this Feb 5, 2026
@rysb-dev rysb-dev merged commit 0558c9d into main Feb 5, 2026
8 checks passed
@rysb-dev rysb-dev deleted the localization-ja branch February 5, 2026 00:36
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