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:
@@ -55,16 +55,16 @@ func GetLogDatabaseStatus(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
store, err := logstore.Active(ctx)
|
||||
if err != nil {
|
||||
logger.ErrorF(ctx, "获取日志存储实例失败: %v", err)
|
||||
response.AbortInternal(c, "日志存储初始化失败")
|
||||
logger.ErrorF(ctx, "Failed to get log storage instance: %v", err)
|
||||
response.AbortInternal(c, "Failed to initialize log storage")
|
||||
return
|
||||
}
|
||||
|
||||
// 分支判定复用同一 store 实例的 ActiveDatabase,避免与 Active 解析之间出现 TOCTOU。
|
||||
activeDB, err := store.Status.ActiveDatabase(ctx)
|
||||
if err != nil {
|
||||
logger.ErrorF(ctx, "获取日志库状态失败: %v", err)
|
||||
response.AbortInternal(c, "获取日志库状态失败")
|
||||
logger.ErrorF(ctx, "Failed to get log database status: %v", err)
|
||||
response.AbortInternal(c, "Failed to get log database status")
|
||||
return
|
||||
}
|
||||
migration := "idle"
|
||||
@@ -86,7 +86,7 @@ func GetLogDatabaseStatus(c *gin.Context) {
|
||||
if activeDB == logDBNameClickHouse {
|
||||
stats, err := store.Status.ClickHouseOperationalStats(ctx)
|
||||
if err != nil {
|
||||
logger.ErrorF(ctx, "获取 ClickHouse 运行指标失败: %v", err)
|
||||
logger.ErrorF(ctx, "Failed to get ClickHouse runtime metrics: %v", err)
|
||||
} else {
|
||||
stats.BatchWriters = collectBatchWriterStats()
|
||||
out.ClickHouse = stats
|
||||
@@ -101,7 +101,7 @@ func retentionOr(ctx context.Context, key string) int {
|
||||
v, err := repository.GetIntByKey(ctx, key)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.ErrorF(ctx, "读取日志保留天数配置失败 key=%s: %v", key, err)
|
||||
logger.ErrorF(ctx, "Failed to read log retention configuration key=%s: %v", key, err)
|
||||
}
|
||||
return defaultLogRetentionDays
|
||||
}
|
||||
|
||||
@@ -120,16 +120,16 @@ func formatDuration(d time.Duration) string {
|
||||
|
||||
var res string
|
||||
if days > 0 {
|
||||
res += fmt.Sprintf("%d天", days)
|
||||
res += fmt.Sprintf("%d days", days)
|
||||
}
|
||||
if hours > 0 {
|
||||
res += fmt.Sprintf("%d小时", hours)
|
||||
res += fmt.Sprintf("%d hours", hours)
|
||||
}
|
||||
if minutes > 0 {
|
||||
res += fmt.Sprintf("%d分钟", minutes)
|
||||
res += fmt.Sprintf("%d minutes", minutes)
|
||||
}
|
||||
if seconds > 0 || res == "" {
|
||||
res += fmt.Sprintf("%d秒钟", seconds)
|
||||
res += fmt.Sprintf("%d seconds", seconds)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -156,9 +156,9 @@ func GetSystemStatus(c *gin.Context) {
|
||||
case m.LastGC > 0 && m.LastGC <= math.MaxInt64:
|
||||
lastGCTime = formatDuration(time.Since(time.Unix(0, int64(m.LastGC))))
|
||||
case m.LastGC > 0:
|
||||
lastGCTime = "未知"
|
||||
lastGCTime = "Unknown"
|
||||
default:
|
||||
lastGCTime = "无"
|
||||
lastGCTime = "None"
|
||||
}
|
||||
|
||||
var lastPause string
|
||||
@@ -292,7 +292,7 @@ func exportSQLite(c *gin.Context) {
|
||||
dir, err := os.MkdirTemp("", "openflare-db-export-*")
|
||||
if err != nil {
|
||||
logger.ErrorF(c.Request.Context(), "[db-export] create temporary directory failed: %v", err)
|
||||
response.AbortInternal(c, "无法创建数据库导出文件")
|
||||
response.AbortInternal(c, "Unable to create database export file")
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
@@ -303,13 +303,13 @@ func exportSQLite(c *gin.Context) {
|
||||
path := filepath.Join(dir, "openflare.db")
|
||||
if err := repository.ExportSQLiteSnapshot(c.Request.Context(), path); err != nil {
|
||||
logger.ErrorF(c.Request.Context(), "[db-export] create SQLite snapshot failed: %v", err)
|
||||
response.AbortInternal(c, "无法导出数据库")
|
||||
response.AbortInternal(c, "Unable to export database")
|
||||
return
|
||||
}
|
||||
|
||||
f, err := os.Open(path) //nolint:gosec // path is generated in a private temporary directory, not from user input
|
||||
if err != nil {
|
||||
response.AbortInternal(c, "无法打开数据库文件: "+err.Error())
|
||||
response.AbortInternal(c, "Unable to open database file: "+err.Error())
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
@@ -320,7 +320,7 @@ func exportSQLite(c *gin.Context) {
|
||||
|
||||
fi, err := f.Stat()
|
||||
if err != nil {
|
||||
response.AbortInternal(c, "无法读取数据库文件信息: "+err.Error())
|
||||
response.AbortInternal(c, "Unable to read database file information: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ func exportPostgres(c *gin.Context) {
|
||||
// 检查 pg_dump 是否可用
|
||||
pgDumpPath, err := exec.LookPath("pg_dump")
|
||||
if err != nil {
|
||||
response.AbortInternal(c, "pg_dump 不可用,请确保服务器已安装 PostgreSQL 客户端工具")
|
||||
response.AbortInternal(c, "pg_dump is unavailable; install the PostgreSQL client tools on the server")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user