mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-16 23:04:24 +08:00
fix(i18n): use English runtime text and localize system UI
This commit is contained in:
@@ -179,7 +179,7 @@ func ListExternalAccountsByUserID(ctx context.Context, userID uint64) ([]model.E
|
||||
if account.AuthSourceID == 0 {
|
||||
name = "default"
|
||||
sourceType = "oidc"
|
||||
label = "历史认证源"
|
||||
label = "Historical authentication source"
|
||||
} else {
|
||||
source, err := GetAuthSourceByID(ctx, account.AuthSourceID)
|
||||
if err != nil {
|
||||
|
||||
+10
-10
@@ -10,16 +10,16 @@ package repository
|
||||
// but do not import or re-export model unexported consts (would require exporting).
|
||||
const (
|
||||
errDatabaseNotInitialized = "database not initialized"
|
||||
errConfigIntParseFailed = "配置 %s 的值 '%s' 无法转换为整数: %w"
|
||||
errConfigDecimalParseFailed = "配置 %s 的值 '%s' 无法转换为decimal: %w"
|
||||
errConfigBoolParseFailed = "配置 %s 的值 '%s' 无法转换为布尔值: %w"
|
||||
errParseMenuDisplayConfigFailed = "解析目录显示配置失败: %w"
|
||||
errAuthSourceNameRequired = "认证源名称不能为空"
|
||||
errAuthSourceIDRequired = "认证源 ID 不能为空"
|
||||
errExternalAccountBindingIncomplete = "外部账号绑定信息不完整"
|
||||
errExternalAccountAlreadyBoundToAnother = "该外部账号已绑定到其他用户"
|
||||
errUserIDRequired = "用户 ID 不能为空"
|
||||
errExternalAccountBindingIDRequired = "绑定记录 ID 不能为空"
|
||||
errConfigIntParseFailed = "cannot convert configuration %s value '%s' to an integer: %w"
|
||||
errConfigDecimalParseFailed = "cannot convert configuration %s value '%s' to a decimal: %w"
|
||||
errConfigBoolParseFailed = "cannot convert configuration %s value '%s' to a boolean: %w"
|
||||
errParseMenuDisplayConfigFailed = "failed to parse directory display configuration: %w"
|
||||
errAuthSourceNameRequired = "authentication source name must not be empty"
|
||||
errAuthSourceIDRequired = "authentication source ID must not be empty"
|
||||
errExternalAccountBindingIncomplete = "external account binding information is incomplete"
|
||||
errExternalAccountAlreadyBoundToAnother = "this external account is bound to another user"
|
||||
errUserIDRequired = "user ID must not be empty"
|
||||
errExternalAccountBindingIDRequired = "account binding ID must not be empty"
|
||||
)
|
||||
|
||||
const colName = "name"
|
||||
|
||||
@@ -53,13 +53,13 @@ func retentionDaysForDatabase(ctx context.Context, dbName string) int {
|
||||
v, err := getConfig(ctx, key)
|
||||
if err != nil {
|
||||
if !errors.Is(err, errConfigReaderNotWired) {
|
||||
logger.ErrorF(ctx, "读取日志保留天数配置失败(key=%s),回退默认 %d 天: %v", key, defaultLogRetentionDays, err)
|
||||
logger.ErrorF(ctx, "Failed to read log retention configuration (key=%s); using default of %d days: %v", key, defaultLogRetentionDays, err)
|
||||
}
|
||||
return defaultLogRetentionDays
|
||||
}
|
||||
days, perr := strconv.Atoi(v)
|
||||
if perr != nil || days <= 0 {
|
||||
logger.ErrorF(ctx, "日志保留天数配置非法(key=%s, value=%q),回退默认 %d 天", key, v, defaultLogRetentionDays)
|
||||
logger.ErrorF(ctx, "Invalid log retention configuration (key=%s, value=%q); using default of %d days", key, v, defaultLogRetentionDays)
|
||||
return defaultLogRetentionDays
|
||||
}
|
||||
return days
|
||||
@@ -70,13 +70,13 @@ func metricRetentionDays(ctx context.Context) int {
|
||||
v, err := getConfig(ctx, model.ConfigKeyMetricRetentionDays)
|
||||
if err != nil {
|
||||
if !errors.Is(err, errConfigReaderNotWired) {
|
||||
logger.ErrorF(ctx, "读取性能指标保留天数配置失败(key=%s),回退默认 %d 天: %v", model.ConfigKeyMetricRetentionDays, defaultMetricRetentionDays, err)
|
||||
logger.ErrorF(ctx, "Failed to read metric retention configuration (key=%s); using default of %d days: %v", model.ConfigKeyMetricRetentionDays, defaultMetricRetentionDays, err)
|
||||
}
|
||||
return defaultMetricRetentionDays
|
||||
}
|
||||
days, perr := strconv.Atoi(v)
|
||||
if perr != nil || days <= 0 {
|
||||
logger.ErrorF(ctx, "性能指标保留天数配置非法(key=%s, value=%q),回退默认 %d 天", model.ConfigKeyMetricRetentionDays, v, defaultMetricRetentionDays)
|
||||
logger.ErrorF(ctx, "Invalid metric retention configuration (key=%s, value=%q); using default of %d days", model.ConfigKeyMetricRetentionDays, v, defaultMetricRetentionDays)
|
||||
return defaultMetricRetentionDays
|
||||
}
|
||||
return days
|
||||
|
||||
@@ -42,7 +42,7 @@ func GetSystemUser(ctx context.Context) model.User {
|
||||
return model.User{
|
||||
ID: 999,
|
||||
Username: configTypeSystem,
|
||||
Nickname: "系统",
|
||||
Nickname: "System",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ func RegisterUserWithChecks(ctx context.Context, user *model.User) error {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
return errors.New("用户名已存在")
|
||||
return errors.New("username already exists")
|
||||
}
|
||||
if user.Email != "" {
|
||||
var emailCount int64
|
||||
@@ -282,7 +282,7 @@ func RegisterUserWithChecks(ctx context.Context, user *model.User) error {
|
||||
return err
|
||||
}
|
||||
if emailCount > 0 {
|
||||
return errors.New("该邮箱已被其他账号绑定")
|
||||
return errors.New("this email address is bound to another account")
|
||||
}
|
||||
}
|
||||
if user.ID == 0 {
|
||||
|
||||
Reference in New Issue
Block a user