mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
feat: add i18n support
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/naiba/nezha/service/singleton"
|
||||
)
|
||||
|
||||
type ioStreamContext struct {
|
||||
@@ -117,13 +119,13 @@ LOOP:
|
||||
}
|
||||
|
||||
if stream.userIo == nil && stream.agentIo == nil {
|
||||
return errors.New("timeout: no connection established")
|
||||
return singleton.Localizer.ErrorT("timeout: no connection established")
|
||||
}
|
||||
if stream.userIo == nil {
|
||||
return errors.New("timeout: user connection not established")
|
||||
return singleton.Localizer.ErrorT("timeout: user connection not established")
|
||||
}
|
||||
if stream.agentIo == nil {
|
||||
return errors.New("timeout: agent connection not established")
|
||||
return singleton.Localizer.ErrorT("timeout: agent connection not established")
|
||||
}
|
||||
|
||||
isDone := new(atomic.Bool)
|
||||
|
||||
@@ -54,11 +54,11 @@ func (s *NezhaHandler) ReportTask(c context.Context, r *pb.TaskResult) (*pb.Rece
|
||||
curServer := model.Server{}
|
||||
copier.Copy(&curServer, singleton.ServerList[clientID])
|
||||
if cr.PushSuccessful && r.GetSuccessful() {
|
||||
singleton.SendNotification(cr.NotificationGroupID, fmt.Sprintf("[%s] %s, %s\n%s", "Scheduled Task Executed Successfully",
|
||||
singleton.SendNotification(cr.NotificationGroupID, fmt.Sprintf("[%s] %s, %s\n%s", singleton.Localizer.T("Scheduled Task Executed Successfully"),
|
||||
cr.Name, singleton.ServerList[clientID].Name, r.GetData()), nil, &curServer)
|
||||
}
|
||||
if !r.GetSuccessful() {
|
||||
singleton.SendNotification(cr.NotificationGroupID, fmt.Sprintf("[%s] %s, %s\n%s", "Scheduled Task Executed Failed",
|
||||
singleton.SendNotification(cr.NotificationGroupID, fmt.Sprintf("[%s] %s, %s\n%s", singleton.Localizer.T("Scheduled Task Executed Failed"),
|
||||
cr.Name, singleton.ServerList[clientID].Name, r.GetData()), nil, &curServer)
|
||||
}
|
||||
singleton.DB.Model(cr).Updates(model.Cron{
|
||||
@@ -153,7 +153,7 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
|
||||
singleton.SendNotification(singleton.Conf.IPChangeNotificationGroupID,
|
||||
fmt.Sprintf(
|
||||
"[%s] %s, %s => %s",
|
||||
"IPChanged",
|
||||
singleton.Localizer.T("IP Changed"),
|
||||
singleton.ServerList[clientID].Name, singleton.IPDesensitize(singleton.ServerList[clientID].Host.IP),
|
||||
singleton.IPDesensitize(host.IP),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user