feat: add i18n support

This commit is contained in:
uubulb
2024-11-01 05:07:04 +08:00
parent 482d787a56
commit 5114fc2854
30 changed files with 930 additions and 91 deletions

View File

@@ -1,7 +1,6 @@
package controller
import (
"fmt"
"slices"
"strconv"
@@ -78,7 +77,7 @@ func createNotificationGroup(c *gin.Context) (uint64, error) {
}
if count != int64(len(ngf.Notifications)) {
return 0, fmt.Errorf("have invalid notification id")
return 0, singleton.Localizer.ErrorT("have invalid notification id")
}
err := singleton.DB.Transaction(func(tx *gorm.DB) error {
@@ -129,7 +128,7 @@ func updateNotificationGroup(c *gin.Context) (any, error) {
}
var ngDB model.NotificationGroup
if err := singleton.DB.First(&ngDB, id).Error; err != nil {
return nil, fmt.Errorf("group id %d does not exist", id)
return nil, singleton.Localizer.ErrorT("group id %d does not exist", id)
}
ngDB.Name = ngf.Name
@@ -140,7 +139,7 @@ func updateNotificationGroup(c *gin.Context) (any, error) {
return nil, newGormError("%v", err)
}
if count != int64(len(ngf.Notifications)) {
return nil, fmt.Errorf("have invalid notification id")
return nil, singleton.Localizer.ErrorT("have invalid notification id")
}
err = singleton.DB.Transaction(func(tx *gorm.DB) error {