mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-12 11:23:42 +08:00
refactor: update UI text and error messages to English for better accessibility
This commit is contained in:
@@ -40,7 +40,7 @@ func SearchRedemptions(keyword string) (redemptions []*Redemption, err error) {
|
||||
|
||||
func GetRedemptionById(id int) (*Redemption, error) {
|
||||
if id == 0 {
|
||||
return nil, errors.New("id 为空!")
|
||||
return nil, errors.New("id is empty!")
|
||||
}
|
||||
redemption := Redemption{Id: id}
|
||||
var err error = nil
|
||||
@@ -50,10 +50,10 @@ func GetRedemptionById(id int) (*Redemption, error) {
|
||||
|
||||
func Redeem(key string, userId int) (quota int64, err error) {
|
||||
if key == "" {
|
||||
return 0, errors.New("未提供兑换码")
|
||||
return 0, errors.New("No redemption code provided")
|
||||
}
|
||||
if userId == 0 {
|
||||
return 0, errors.New("无效的 user id")
|
||||
return 0, errors.New("Invalid user id")
|
||||
}
|
||||
redemption := &Redemption{}
|
||||
|
||||
@@ -65,10 +65,10 @@ func Redeem(key string, userId int) (quota int64, err error) {
|
||||
err = DB.Transaction(func(tx *gorm.DB) error {
|
||||
err := tx.Set("gorm:query_option", "FOR UPDATE").Where(keyCol+" = ?", key).First(redemption).Error
|
||||
if err != nil {
|
||||
return errors.New("无效的兑换码")
|
||||
return errors.New("Invalid redemption code")
|
||||
}
|
||||
if redemption.Status != RedemptionCodeStatusEnabled {
|
||||
return errors.New("该兑换码已被使用")
|
||||
return errors.New("The redemption code has been used")
|
||||
}
|
||||
err = tx.Model(&User{}).Where("id = ?", userId).Update("quota", gorm.Expr("quota + ?", redemption.Quota)).Error
|
||||
if err != nil {
|
||||
@@ -80,9 +80,9 @@ func Redeem(key string, userId int) (quota int64, err error) {
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return 0, errors.New("兑换失败," + err.Error())
|
||||
return 0, errors.New("Redeem失败," + err.Error())
|
||||
}
|
||||
RecordLog(userId, LogTypeTopup, fmt.Sprintf("通过兑换码充值 %s", common.LogQuota(redemption.Quota)))
|
||||
RecordLog(userId, LogTypeTopup, fmt.Sprintf("Recharge %s through redemption code", common.LogQuota(redemption.Quota)))
|
||||
return redemption.Quota, nil
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func (redemption *Redemption) Delete() error {
|
||||
|
||||
func DeleteRedemptionById(id int) (err error) {
|
||||
if id == 0 {
|
||||
return errors.New("id 为空!")
|
||||
return errors.New("id is empty!")
|
||||
}
|
||||
redemption := Redemption{Id: id}
|
||||
err = DB.Where(redemption).First(&redemption).Error
|
||||
|
||||
Reference in New Issue
Block a user