use i18n error when import rules and dashboards

This commit is contained in:
UlricQin 2021-12-02 10:19:10 +08:00
parent dd8e1f2d71
commit 4e3f9914f1
2 changed files with 4 additions and 2 deletions

View File

@ -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] = ""
}

View File

@ -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
}