perf: BaseManager email subject translate

This commit is contained in:
wangruidong 2025-03-12 19:02:41 +08:00 committed by w940853815
parent 30e64ecfc1
commit 28f85a0186
2 changed files with 50 additions and 45 deletions

View File

@ -3,10 +3,10 @@ import json
import logging import logging
import os import os
import shutil import shutil
import time
from collections import defaultdict from collections import defaultdict
from socket import gethostname from socket import gethostname
import time
import yaml import yaml
from django.conf import settings from django.conf import settings
from django.template.loader import render_to_string from django.template.loader import render_to_string
@ -137,24 +137,15 @@ class BaseManager:
raise NotImplementedError raise NotImplementedError
def get_report_subject(self): def get_report_subject(self):
return f"Automation {self.execution.id} finished" return _("Task: {} finished").format(self.execution.automation.name)
def get_report_context(self): def get_report_context(self):
logo = self.get_file_content("static/img/JumpServer_white_logo.svg")
return { return {
"execution": self.execution, "execution": self.execution,
"summary": self.execution.summary, "summary": self.execution.summary,
"result": self.execution.result, "result": self.execution.result
"logo": logo,
} }
@staticmethod
def get_file_content(path):
file_path = os.path.join(settings.BASE_DIR, path)
with open(file_path, "r", encoding="utf-8") as f:
file_content = f.read()
return file_content
def send_report_if_need(self): def send_report_if_need(self):
recipients = self.execution.recipients recipients = self.execution.recipients
if not recipients: if not recipients:

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: JumpServer 0.3.3\n" "Project-Id-Version: JumpServer 0.3.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-12 17:42+0800\n" "POT-Creation-Date: 2025-03-12 18:56+0800\n"
"PO-Revision-Date: 2021-05-20 10:54+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n"
"Last-Translator: ibuler <ibuler@qq.com>\n" "Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: JumpServer team<ibuler@qq.com>\n" "Language-Team: JumpServer team<ibuler@qq.com>\n"
@ -136,6 +136,8 @@ msgstr ">>> 开始执行测试网关账号可连接性任务"
#: users/templates/users/_msg_user_created.html:13 #: users/templates/users/_msg_user_created.html:13
#: users/templates/users/user_password_verify.html:18 #: users/templates/users/user_password_verify.html:18
#: xpack/plugins/cloud/serializers/account_attrs.py:28 #: xpack/plugins/cloud/serializers/account_attrs.py:28
#: xpack/plugins/cloud/serializers/account_attrs.py:90
#: xpack/plugins/cloud/serializers/account_attrs.py:97
msgid "Password" msgid "Password"
msgstr "密码" msgstr "密码"
@ -865,6 +867,8 @@ msgstr "重复密码"
#: users/forms/profile.py:117 users/models/user/__init__.py:59 #: users/forms/profile.py:117 users/models/user/__init__.py:59
#: users/templates/users/_msg_user_created.html:12 #: users/templates/users/_msg_user_created.html:12
#: xpack/plugins/cloud/serializers/account_attrs.py:26 #: xpack/plugins/cloud/serializers/account_attrs.py:26
#: xpack/plugins/cloud/serializers/account_attrs.py:88
#: xpack/plugins/cloud/serializers/account_attrs.py:95
msgid "Username" msgid "Username"
msgstr "用户名" msgstr "用户名"
@ -1895,8 +1899,8 @@ msgid ""
"10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64 (Domain name " "10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64 (Domain name "
"support)" "support)"
msgstr "" msgstr ""
"* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:" "* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, "
"db8:2de::e13, 2001:db8:1a:1110::/64 (支持网域)" "2001:db8:2de::e13, 2001:db8:1a:1110::/64 (支持网域)"
#: acls/serializers/base.py:41 assets/serializers/asset/host.py:19 #: acls/serializers/base.py:41 assets/serializers/asset/host.py:19
msgid "IP/Host" msgid "IP/Host"
@ -1924,8 +1928,8 @@ msgid ""
"With * indicating a match all. Such as: 192.168.10.1, 192.168.1.0/24, " "With * indicating a match all. Such as: 192.168.10.1, 192.168.1.0/24, "
"10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64 " "10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64 "
msgstr "" msgstr ""
"* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:" "* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, "
"db8:2de::e13, 2001:db8:1a:1110::/64" "2001:db8:2de::e13, 2001:db8:1a:1110::/64"
#: acls/serializers/rules/rules.py:33 #: acls/serializers/rules/rules.py:33
#: authentication/templates/authentication/_msg_oauth_bind.html:12 #: authentication/templates/authentication/_msg_oauth_bind.html:12
@ -2025,28 +2029,32 @@ msgstr "同级别节点名字不能重复"
msgid "App Assets" msgid "App Assets"
msgstr "资产管理" msgstr "资产管理"
#: assets/automations/base/manager.py:347 #: assets/automations/base/manager.py:140
msgid "Task: {} finished"
msgstr "任务:{} 完成"
#: assets/automations/base/manager.py:338
msgid " - Platform {} ansible disabled" msgid " - Platform {} ansible disabled"
msgstr " - 平台 {} Ansible 已禁用, 无法执行任务" msgstr " - 平台 {} Ansible 已禁用, 无法执行任务"
#: assets/automations/base/manager.py:530 #: assets/automations/base/manager.py:521
msgid ">>> Task preparation phase" msgid ">>> Task preparation phase"
msgstr ">>> 任务准备阶段" msgstr ">>> 任务准备阶段"
#: assets/automations/base/manager.py:534 #: assets/automations/base/manager.py:525
#, python-brace-format #, python-brace-format
msgid ">>> Executing tasks in batches, total {runner_count}" msgid ">>> Executing tasks in batches, total {runner_count}"
msgstr ">>> 分次执行任务,总共 {runner_count}" msgstr ">>> 分次执行任务,总共 {runner_count}"
#: assets/automations/base/manager.py:539 #: assets/automations/base/manager.py:530
msgid ">>> Start executing tasks" msgid ">>> Start executing tasks"
msgstr ">>> 开始执行任务" msgstr ">>> 开始执行任务"
#: assets/automations/base/manager.py:541 #: assets/automations/base/manager.py:532
msgid ">>> No tasks need to be executed" msgid ">>> No tasks need to be executed"
msgstr ">>> 没有需要执行的任务" msgstr ">>> 没有需要执行的任务"
#: assets/automations/base/manager.py:545 #: assets/automations/base/manager.py:536
#, python-brace-format #, python-brace-format
msgid ">>> Begin executing batch {index} of tasks" msgid ">>> Begin executing batch {index} of tasks"
msgstr ">>> 开始执行第 {index} 批任务" msgstr ">>> 开始执行第 {index} 批任务"
@ -2144,7 +2152,8 @@ msgstr "云服务"
msgid "Web" msgid "Web"
msgstr "Web" msgstr "Web"
#: assets/const/category.py:15 common/sdk/sms/endpoint.py:20 #: assets/const/category.py:15 common/sdk/sms/custom_file.py:47
#: common/sdk/sms/endpoint.py:20
msgid "Custom type" msgid "Custom type"
msgstr "自定义类型" msgstr "自定义类型"
@ -2836,7 +2845,7 @@ msgstr "端口超出范围 (0-65535)"
msgid "Protocol is required: {}" msgid "Protocol is required: {}"
msgstr "协议是必填的: {}" msgstr "协议是必填的: {}"
#: assets/serializers/asset/common.py:350 #: assets/serializers/asset/common.py:350 labels/api.py:107
msgid "Invalid data" msgid "Invalid data"
msgstr "无效的数据" msgstr "无效的数据"
@ -4940,6 +4949,10 @@ msgstr "自定义短信文件无效"
msgid "SMS sending failed[%s]: %s" msgid "SMS sending failed[%s]: %s"
msgstr "短信发送失败[%s]: %s" msgstr "短信发送失败[%s]: %s"
#: common/sdk/sms/custom_file.py:47 common/serializers/common.py:98
msgid "File"
msgstr "文件"
#: common/sdk/sms/endpoint.py:16 #: common/sdk/sms/endpoint.py:16
msgid "Alibaba cloud" msgid "Alibaba cloud"
msgstr "阿里云" msgstr "阿里云"
@ -4984,10 +4997,6 @@ msgstr "请在 {} 秒后发送"
msgid "Children" msgid "Children"
msgstr "节点" msgstr "节点"
#: common/serializers/common.py:98
msgid "File"
msgstr "文件"
#: common/serializers/fields.py:139 #: common/serializers/fields.py:139
msgid "Invalid data type" msgid "Invalid data type"
msgstr "无效的数据" msgstr "无效的数据"
@ -5108,6 +5117,10 @@ msgstr "你的账号已创建成功"
msgid "JumpServer - An open-source PAM" msgid "JumpServer - An open-source PAM"
msgstr "JumpServer 开源堡垒机" msgstr "JumpServer 开源堡垒机"
#: jumpserver/context_processor.py:28
msgid "FIT2CLOUD"
msgstr ""
#: jumpserver/views/celery_flower.py:22 #: jumpserver/views/celery_flower.py:22
msgid "<h1>Flower service unavailable, check it</h1>" msgid "<h1>Flower service unavailable, check it</h1>"
msgstr "Flower 服务不可用,请检查" msgstr "Flower 服务不可用,请检查"
@ -7109,7 +7122,7 @@ msgstr "租户 ID"
#: settings/serializers/feature.py:110 terminal/serializers/storage.py:68 #: settings/serializers/feature.py:110 terminal/serializers/storage.py:68
#: xpack/plugins/cloud/manager.py:111 xpack/plugins/cloud/manager.py:116 #: xpack/plugins/cloud/manager.py:111 xpack/plugins/cloud/manager.py:116
#: xpack/plugins/cloud/models.py:287 #: xpack/plugins/cloud/manager.py:153 xpack/plugins/cloud/models.py:287
msgid "Region" msgid "Region"
msgstr "地域" msgstr "地域"
@ -8056,7 +8069,7 @@ msgstr "会话不存在: {}"
msgid "Session is finished or the protocol not supported" msgid "Session is finished or the protocol not supported"
msgstr "会话已经完成或协议不支持" msgstr "会话已经完成或协议不支持"
#: terminal/api/session/session.py:345 #: terminal/api/session/session.py:345 tickets/api/ticket.py:140
msgid "User does not have permission" msgid "User does not have permission"
msgstr "用户没有权限" msgstr "用户没有权限"
@ -8600,9 +8613,9 @@ msgid ""
"days. <a href=\"https://learn.microsoft.com/en-us/windows-server/remote/" "days. <a href=\"https://learn.microsoft.com/en-us/windows-server/remote/"
"remote-desktop-services/rds-client-access-license\">Detail</a>" "remote-desktop-services/rds-client-access-license\">Detail</a>"
msgstr "" msgstr ""
"如果不存在RDS 将处于试用模式,试用期为 120 天。<a href='https://learn." "如果不存在RDS 将处于试用模式,试用期为 120 天。<a href='https://"
"microsoft.com/en-us/windows-server/remote/remote-desktop-services/rds-client-" "learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/rds-"
"access-license'>详情</a>" "client-access-license'>详情</a>"
#: terminal/serializers/applet_host.py:55 #: terminal/serializers/applet_host.py:55
msgid "RDS License Server" msgid "RDS License Server"
@ -8836,8 +8849,8 @@ msgid ""
"If there are multiple hosts, use a comma (,) to separate them. <br>(For " "If there are multiple hosts, use a comma (,) to separate them. <br>(For "
"example: http://www.jumpserver.a.com:9100, http://www.jumpserver.b.com:9100)" "example: http://www.jumpserver.a.com:9100, http://www.jumpserver.b.com:9100)"
msgstr "" msgstr ""
"如果有多个主机,请用逗号 (,) 分隔它们。<br>例如http://www.jumpserver.a." "如果有多个主机,请用逗号 (,) 分隔它们。<br>例如http://"
"com:9100http://www.jumpserver.b.com:9100" "www.jumpserver.a.com:9100http://www.jumpserver.b.com:9100"
#: terminal/serializers/storage.py:199 #: terminal/serializers/storage.py:199
msgid "Index by date" msgid "Index by date"
@ -10450,6 +10463,10 @@ msgstr "同步地区"
msgid "Get instances of region \"%s\" error, error: %s" msgid "Get instances of region \"%s\" error, error: %s"
msgstr "获取区域 \"%s\" 的实例错误,错误:%s" msgstr "获取区域 \"%s\" 的实例错误,错误:%s"
#: xpack/plugins/cloud/manager.py:153 xpack/plugins/cloud/models.py:284
msgid "Instance"
msgstr "实例"
#: xpack/plugins/cloud/manager.py:179 #: xpack/plugins/cloud/manager.py:179
#, python-format #, python-format
msgid "Failed to synchronize the instance \"%s\"" msgid "Failed to synchronize the instance \"%s\""
@ -10592,10 +10609,6 @@ msgstr "同步任务"
msgid "Sync instance task history" msgid "Sync instance task history"
msgstr "同步实例任务历史" msgstr "同步实例任务历史"
#: xpack/plugins/cloud/models.py:284
msgid "Instance"
msgstr "实例"
#: xpack/plugins/cloud/models.py:301 #: xpack/plugins/cloud/models.py:301
msgid "Sync instance detail" msgid "Sync instance detail"
msgstr "同步实例详情" msgstr "同步实例详情"
@ -10900,6 +10913,12 @@ msgstr "订阅 ID"
msgid "Auto node classification" msgid "Auto node classification"
msgstr "自动节点分类" msgstr "自动节点分类"
#: xpack/plugins/cloud/serializers/account_attrs.py:93
#, fuzzy
#| msgid "Container name"
msgid "domain_name"
msgstr "容器名称"
#: xpack/plugins/cloud/serializers/account_attrs.py:99 #: xpack/plugins/cloud/serializers/account_attrs.py:99
#: xpack/plugins/cloud/serializers/account_attrs.py:103 #: xpack/plugins/cloud/serializers/account_attrs.py:103
#: xpack/plugins/cloud/serializers/account_attrs.py:127 #: xpack/plugins/cloud/serializers/account_attrs.py:127
@ -11095,8 +11114,3 @@ msgstr "许可证无效"
#~ msgid "" #~ msgid ""
#~ "The following is a summary of account push tasks, please read and process" #~ "The following is a summary of account push tasks, please read and process"
#~ msgstr "以下是账号推送任务的汇总,请阅读并处理" #~ msgstr "以下是账号推送任务的汇总,请阅读并处理"
#, fuzzy
#~| msgid "Container name"
#~ msgid "domain_name"
#~ msgstr "容器名称"