From 411b485448c17ecadce776d71137f0b10e7855ba Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Thu, 19 Jun 2025 14:47:17 +0800 Subject: [PATCH] fix: The title of the risk detection email and server performance check notification i18n --- .../automations/check_account/manager.py | 2 +- apps/i18n/core/zh/LC_MESSAGES/django.po | 86 +++++++++++-------- apps/ops/notifications.py | 21 +++-- 3 files changed, 66 insertions(+), 43 deletions(-) diff --git a/apps/accounts/automations/check_account/manager.py b/apps/accounts/automations/check_account/manager.py index c62b7e5d7..c8d1101c4 100644 --- a/apps/accounts/automations/check_account/manager.py +++ b/apps/accounts/automations/check_account/manager.py @@ -264,7 +264,7 @@ class CheckAccountManager(BaseManager): handler.clean() def get_report_subject(self): - return "Check account report of %s" % self.execution.id + return _("Check account report of {}").format(self.execution.id) def get_report_template(self): return "accounts/check_account_report.html" diff --git a/apps/i18n/core/zh/LC_MESSAGES/django.po b/apps/i18n/core/zh/LC_MESSAGES/django.po index 0e4770c1a..25a033a38 100644 --- a/apps/i18n/core/zh/LC_MESSAGES/django.po +++ b/apps/i18n/core/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: JumpServer 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-06-18 14:56+0800\n" +"POT-Creation-Date: 2025-06-19 14:43+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -102,6 +102,10 @@ msgstr "未找到待处理帐户" msgid "Success: %s, Failed: %s, Total: %s" msgstr "成功: %s, 失败: %s, 总数: %s" +#: accounts/automations/check_account/manager.py:267 +msgid "Check account report of {}" +msgstr "风险检测报告 {}" + #: accounts/automations/check_account/manager.py:273 msgid "" "---\n" @@ -136,6 +140,8 @@ msgstr ">>> 开始执行测试网关账号可连接性任务" #: users/templates/users/_msg_user_created.html:13 #: users/templates/users/user_password_verify.html:18 #: xpack/plugins/cloud/serializers/account_attrs.py:43 +#: xpack/plugins/cloud/serializers/account_attrs.py:105 +#: xpack/plugins/cloud/serializers/account_attrs.py:112 msgid "Password" msgstr "密码" @@ -869,6 +875,8 @@ msgstr "重复密码" #: users/serializers/profile.py:190 #: users/templates/users/_msg_user_created.html:12 #: xpack/plugins/cloud/serializers/account_attrs.py:41 +#: xpack/plugins/cloud/serializers/account_attrs.py:103 +#: xpack/plugins/cloud/serializers/account_attrs.py:110 msgid "Username" msgstr "用户名" @@ -1933,8 +1941,8 @@ msgid "" "10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64 (Domain name " "support)" msgstr "" -"* 表示匹配所有。例如: 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 (支持网域)" +"* 表示匹配所有。例如: 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 (支持网域)" #: acls/serializers/base.py:41 assets/serializers/asset/host.py:19 msgid "IP/Host" @@ -1962,8 +1970,8 @@ msgid "" "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 " msgstr "" -"* 表示匹配所有。例如: 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" +"* 表示匹配所有。例如: 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" #: acls/serializers/rules/rules.py:33 #: authentication/templates/authentication/_msg_oauth_bind.html:12 @@ -2212,7 +2220,8 @@ msgstr "云服务" msgid "Web" msgstr "Web" -#: assets/const/category.py:16 common/sdk/sms/endpoint.py:20 +#: assets/const/category.py:16 common/sdk/sms/custom_file.py:47 +#: common/sdk/sms/endpoint.py:20 msgid "Custom type" msgstr "自定义类型" @@ -2914,7 +2923,7 @@ msgstr "端口超出范围 (0-65535)" msgid "Protocol is required: {}" msgstr "协议是必填的: {}" -#: assets/serializers/asset/common.py:353 +#: assets/serializers/asset/common.py:353 labels/api.py:107 msgid "Invalid data" msgstr "无效的数据" @@ -3360,7 +3369,7 @@ msgstr "结束" #: audits/const.py:47 settings/serializers/terminal.py:6 #: terminal/models/applet/host.py:26 terminal/models/component/terminal.py:185 #: terminal/models/virtualapp/provider.py:14 terminal/serializers/session.py:65 -#: terminal/serializers/session.py:178 +#: terminal/serializers/session.py:180 msgid "Terminal" msgstr "终端" @@ -4369,8 +4378,8 @@ msgid "" "Retention Period" msgstr "" "系统在连接资产或创建临时密码时,会生成相应的连接 Token 或临时密码记录。为了保" -"障系统安全并控制数据存储量,系统会根据“安全设置 > 密码安全 > Token 保留时" -"长”中的配置,每天凌晨 2 点自动清理所有已过期的 Token 记录" +"障系统安全并控制数据存储量,系统会根据“安全设置 > 密码安全 > Token 保留时长”" +"中的配置,每天凌晨 2 点自动清理所有已过期的 Token 记录" #: authentication/templates/authentication/_access_key_modal.html:6 msgid "API key list" @@ -5082,6 +5091,10 @@ msgstr "自定义短信文件无效" msgid "SMS sending failed[%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 msgid "Alibaba cloud" msgstr "阿里云" @@ -5126,10 +5139,6 @@ msgstr "请在 {} 秒后发送" msgid "Children" msgstr "节点" -#: common/serializers/common.py:98 -msgid "File" -msgstr "文件" - #: common/serializers/fields.py:139 msgid "Invalid data type" msgstr "无效的数据" @@ -5252,6 +5261,10 @@ msgstr "你的账号已创建成功" msgid "JumpServer - An open-source PAM" msgstr "JumpServer 开源堡垒机" +#: jumpserver/context_processor.py:28 +msgid "FIT2CLOUD" +msgstr "" + #: jumpserver/views/celery_flower.py:22 msgid "

Flower service unavailable, check it

" msgstr "Flower 服务不可用,请检查" @@ -5265,11 +5278,11 @@ msgstr "" "
Luna是单独部署的一个程序,你需要部署luna,koko,
如果你看到了" "这个页面,证明你访问的不是nginx监听的端口,祝你好运
" -#: jumpserver/views/other.py:76 +#: jumpserver/views/other.py:80 msgid "Websocket server run on port: {}, you should proxy it on nginx" msgstr "Websocket 服务运行在端口: {}, 请检查nginx是否代理是否设置" -#: jumpserver/views/other.py:90 +#: jumpserver/views/other.py:94 msgid "" "
Koko is a separately deployed program, you need to deploy Koko, " "configure nginx for url distribution,
If you see this page, " @@ -5743,26 +5756,26 @@ msgstr "变量" msgid "Server performance" msgstr "监控告警" -#: ops/notifications.py:26 +#: ops/notifications.py:27 msgid "Component health check warning" msgstr "组件健康状况检查警告" -#: ops/notifications.py:71 +#: ops/notifications.py:80 #, python-brace-format msgid "The component is offline: {name}" msgstr "组件已离线: {name}" -#: ops/notifications.py:76 +#: ops/notifications.py:85 #, python-brace-format msgid "Disk used more than {max_threshold}%: => {value}" msgstr "硬盘使用率超过 {max_threshold}%: => {value}" -#: ops/notifications.py:81 +#: ops/notifications.py:90 #, python-brace-format msgid "Memory used more than {max_threshold}%: => {value}" msgstr "内存使用率超过 {max_threshold}%: => {value}" -#: ops/notifications.py:86 +#: ops/notifications.py:95 #, python-brace-format msgid "CPU load more than {max_threshold}: => {value}" msgstr "CPU 使用率超过 {max_threshold}: => {value}" @@ -7256,7 +7269,7 @@ msgstr "租户 ID" #: settings/serializers/feature.py:110 terminal/serializers/storage.py:68 #: xpack/plugins/cloud/manager.py:119 xpack/plugins/cloud/manager.py:124 -#: xpack/plugins/cloud/models.py:292 +#: xpack/plugins/cloud/manager.py:161 xpack/plugins/cloud/models.py:292 msgid "Region" msgstr "地域" @@ -8245,7 +8258,7 @@ msgstr "会话不存在: {}" msgid "Session is finished or the protocol not supported" msgstr "会话已经完成或协议不支持" -#: terminal/api/session/session.py:345 +#: terminal/api/session/session.py:345 tickets/api/ticket.py:140 msgid "User does not have permission" msgstr "用户没有权限" @@ -8613,7 +8626,7 @@ msgstr "登录来源" msgid "Replay" msgstr "回放" -#: terminal/models/session/session.py:50 terminal/serializers/session.py:177 +#: terminal/models/session/session.py:50 terminal/serializers/session.py:179 msgid "Command amount" msgstr "命令数量" @@ -8797,9 +8810,9 @@ msgid "" "days. Detail" msgstr "" -"如果不存在,RDS 将处于试用模式,试用期为 120 天。详情" +"如果不存在,RDS 将处于试用模式,试用期为 120 天。详情" #: terminal/serializers/applet_host.py:55 msgid "RDS License Server" @@ -9017,8 +9030,8 @@ msgid "" "If there are multiple hosts, use a comma (,) to separate them.
(For " "example: http://www.jumpserver.a.com:9100, http://www.jumpserver.b.com:9100)" msgstr "" -"如果有多个主机,请用逗号 (,) 分隔它们。
(例如:http://www.jumpserver.a." -"com:9100,http://www.jumpserver.b.com:9100)" +"如果有多个主机,请用逗号 (,) 分隔它们。
(例如:http://" +"www.jumpserver.a.com:9100,http://www.jumpserver.b.com:9100)" #: terminal/serializers/storage.py:199 msgid "Index by date" @@ -10620,6 +10633,10 @@ msgstr "同步地区" msgid "Get instances of region \"%s\" error, error: %s" msgstr "获取区域 \"%s\" 的实例错误,错误:%s" +#: xpack/plugins/cloud/manager.py:161 xpack/plugins/cloud/models.py:289 +msgid "Instance" +msgstr "实例" + #: xpack/plugins/cloud/manager.py:187 #, python-format msgid "Failed to synchronize the instance \"%s\"" @@ -10762,10 +10779,6 @@ msgstr "同步任务" msgid "Sync instance task history" msgstr "同步实例任务历史" -#: xpack/plugins/cloud/models.py:289 -msgid "Instance" -msgstr "实例" - #: xpack/plugins/cloud/models.py:306 msgid "Sync instance detail" msgstr "同步实例详情" @@ -11070,6 +11083,10 @@ msgstr "订阅 ID" msgid "Auto node classification" msgstr "自动节点分类" +#: xpack/plugins/cloud/serializers/account_attrs.py:108 +msgid "domain_name" +msgstr "域名称" + #: xpack/plugins/cloud/serializers/account_attrs.py:114 #: xpack/plugins/cloud/serializers/account_attrs.py:118 #: xpack/plugins/cloud/serializers/account_attrs.py:150 @@ -11233,6 +11250,3 @@ msgstr "许可证无效" #~ "When creating or modifying an account requires account push, this task is " #~ "executed" #~ msgstr "当创建账号,修改账号时,需要账号推送时执行该任务" - -#~ msgid "domain_name" -#~ msgstr "域名称" diff --git a/apps/ops/notifications.py b/apps/ops/notifications.py index 46e9a5aa5..0bf336864 100644 --- a/apps/ops/notifications.py +++ b/apps/ops/notifications.py @@ -23,9 +23,18 @@ class ServerPerformanceMessage(SystemMessage): self.terms_with_errors = terms_with_errors def get_html_msg(self) -> dict: + terms_with_errors = [] subject = gettext("Component health check warning") + for term, errors in self.terms_with_errors: + formatted_errors = [] + for error in errors: + item, kwargs = error + # format 不能提前,否则会用系统默认语言翻译 + msg = item.format(**kwargs) + formatted_errors.append(msg) + terms_with_errors.append((term, formatted_errors)) context = { - 'terms_with_errors': self.terms_with_errors + 'terms_with_errors': terms_with_errors } message = render_to_string('ops/_msg_terminal_performance.html', context) return { @@ -108,10 +117,10 @@ class ServerPerformanceCheckUtil(object): def check_terminal(self, term): errors = [] for item, data in self.items_mapper.items(): - error = self.check_item(term, item, data) - if not error: + result = self.check_item(term, item, data) + if not result: continue - errors.append(error) + errors.append(result) return errors @staticmethod @@ -125,8 +134,8 @@ class ServerPerformanceCheckUtil(object): elif isinstance(value, (int, float)) and value < max_threshold: return msg = data['alarm_msg_format'] - error = msg.format(max_threshold=max_threshold, value=value, name=term.name) - return error + kwargs = {'name': term.name, 'value': value, 'max_threshold': max_threshold} + return msg, kwargs def publish(self): if not self.terms_with_errors: