mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 00:46:42 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user