feat(i18n): per-session language preference and !lang command

Phase A plumbing for #188. Adds a users.language column (migration
0022), UserRepo.GetLanguage/SetLanguage, and Session.Lang()/SetLang
accessors so future phases can resolve localized content per session
instead of falling back to the server-wide config.Language.

The preference is loaded from the DB on login and persisted via a new
!lang <en|jp|fr|es> chat command that shows the current language when
called without an argument, validates the code (case-insensitive), and
replies in the newly selected language so the switch is visible
immediately. An empty stored value falls back to config.Language.

sys_language.go exposes getLangStringsFor(code) as the new dispatch
primitive; getLangStrings(server) is now a thin wrapper so existing
callers keep working unchanged. isSupportedLang + supportedLangs keep
the !lang validator in sync with the dispatcher.

Localized quest/scenario content and per-session i18n lookups in
existing handlers are deliberately out of scope for phase A — this
commit ships only the plumbing so it can be reviewed and deployed
independently.
This commit is contained in:
Houmgaor
2026-04-06 19:52:19 +02:00
parent 803996adac
commit 5b38bfde3f
18 changed files with 341 additions and 8 deletions

View File

@@ -39,6 +39,11 @@ func langJapanese() i18n {
i.commands.timer.enabled = "クエストタイマーが有効になりました"
i.commands.timer.disabled = "クエストタイマーが無効になりました"
i.commands.lang.usage = "使い方: %s <en|jp|fr|es>"
i.commands.lang.invalid = "未対応の言語 %q。対応言語: en, jp, fr, es"
i.commands.lang.success = "言語を %s に設定しました"
i.commands.lang.current = "現在の言語: %s"
i.commands.ravi.noCommand = "ラヴィコマンドが指定されていません"
i.commands.ravi.start.success = "大討伐を開始します"
i.commands.ravi.start.error = "大討伐は既に開催されています"