From 4e3f9914f1a63b4349afffa839c0e3ed00932c2a Mon Sep 17 00:00:00 2001 From: UlricQin Date: Thu, 2 Dec 2021 10:19:10 +0800 Subject: [PATCH] use i18n error when import rules and dashboards --- src/webapi/router/router_alert_rule.go | 3 ++- src/webapi/router/router_dashboard.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/webapi/router/router_alert_rule.go b/src/webapi/router/router_alert_rule.go index 6d6556d6..cdd3529f 100644 --- a/src/webapi/router/router_alert_rule.go +++ b/src/webapi/router/router_alert_rule.go @@ -6,6 +6,7 @@ import ( "github.com/gin-gonic/gin" "github.com/toolkits/pkg/ginx" + "github.com/toolkits/pkg/i18n" "github.com/didi/nightingale/v5/src/models" ) @@ -46,7 +47,7 @@ func alertRuleAdd(c *gin.Context) { lst[i].FE2DB() if err := lst[i].Add(); err != nil { - reterr[lst[i].Name] = err.Error() + reterr[lst[i].Name] = i18n.Sprintf(c.GetHeader("X-Language"), err.Error()) } else { reterr[lst[i].Name] = "" } diff --git a/src/webapi/router/router_dashboard.go b/src/webapi/router/router_dashboard.go index 77d73a0a..46fdbb91 100644 --- a/src/webapi/router/router_dashboard.go +++ b/src/webapi/router/router_dashboard.go @@ -7,6 +7,7 @@ import ( "github.com/gin-gonic/gin" "github.com/toolkits/pkg/ginx" + "github.com/toolkits/pkg/i18n" "github.com/didi/nightingale/v5/src/models" ) @@ -186,7 +187,7 @@ func dashboardImport(c *gin.Context) { err := dash.Add() if err != nil { - ret[dash.Name] = err.Error() + ret[dash.Name] = i18n.Sprintf(c.GetHeader("X-Language"), err.Error()) continue }