fix(i18n): add missing translations and improve language fallback

- Change default language fallback to English instead of Chinese
- Add ErrRedeemFailed typed error for model layer translation
- Migrate remaining hardcoded messages in controller/user.go
- Add translation keys: redeem.failed, user.create_default_token_error, common.uuid_duplicate, common.invalid_input
This commit is contained in:
CaIon
2026-02-05 00:16:17 +08:00
parent f60fce6584
commit 42b5aeaae4
5 changed files with 36 additions and 29 deletions

View File

@@ -11,6 +11,9 @@ import (
"gorm.io/gorm"
)
// ErrRedeemFailed is returned when redemption fails due to database error
var ErrRedeemFailed = errors.New("redeem.failed")
type Redemption struct {
Id int `json:"id"`
UserId int `json:"user_id"`
@@ -149,7 +152,7 @@ func Redeem(key string, userId int) (quota int, err error) {
})
if err != nil {
common.SysError("redemption failed: " + err.Error())
return 0, errors.New("兑换失败,请稍后重试")
return 0, ErrRedeemFailed
}
RecordLog(userId, LogTypeTopup, fmt.Sprintf("通过兑换码充值 %s兑换码ID %d", logger.LogQuota(redemption.Quota), redemption.Id))
return redemption.Quota, nil