mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-05-06 22:35:11 +02:00
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:
@@ -159,6 +159,13 @@ type UserRepo interface {
|
||||
SetPasswordByDiscordID(discordID string, hash []byte) error
|
||||
GetByIDAndUsername(charID uint32) (userID uint32, username string, err error)
|
||||
BanUser(userID uint32, expires *time.Time) error
|
||||
// GetLanguage returns the user's preferred language code (e.g. "en", "jp").
|
||||
// An empty string means the user has no preference set and the server
|
||||
// default should be used.
|
||||
GetLanguage(userID uint32) (string, error)
|
||||
// SetLanguage stores the user's preferred language code. Passing an empty
|
||||
// string clears the preference (reverts to server default on next login).
|
||||
SetLanguage(userID uint32, lang string) error
|
||||
}
|
||||
|
||||
// GachaRepo defines the contract for gacha system data access.
|
||||
|
||||
Reference in New Issue
Block a user