perf: 优化英文下树的显示 (#7883)

* perf: 优化英文下树的显示

* perf: 修改翻译

* perf: 修改翻译

Co-authored-by: ibuler <ibuler@qq.com>
pull/7886/head^2
fit2bot 2022-03-16 20:27:38 +08:00 committed by GitHub
parent 8233c69038
commit 3b507dc795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 62 deletions

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: 2022-03-16 17:35+0800\n" "POT-Creation-Date: 2022-03-16 19:59+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"
@ -26,7 +26,7 @@ msgstr "访问控制"
#: assets/models/base.py:175 assets/models/cluster.py:18 #: assets/models/base.py:175 assets/models/cluster.py:18
#: assets/models/cmd_filter.py:27 assets/models/domain.py:23 #: assets/models/cmd_filter.py:27 assets/models/domain.py:23
#: assets/models/group.py:20 assets/models/label.py:18 ops/mixin.py:24 #: assets/models/group.py:20 assets/models/label.py:18 ops/mixin.py:24
#: orgs/models.py:12 perms/models/base.py:83 rbac/models/role.py:29 #: orgs/models.py:65 perms/models/base.py:83 rbac/models/role.py:29
#: settings/models.py:29 settings/serializers/sms.py:6 #: settings/models.py:29 settings/serializers/sms.py:6
#: terminal/models/storage.py:23 terminal/models/task.py:16 #: terminal/models/storage.py:23 terminal/models/task.py:16
#: terminal/models/terminal.py:100 users/forms/profile.py:32 #: terminal/models/terminal.py:100 users/forms/profile.py:32
@ -62,7 +62,7 @@ msgstr "激活中"
#: assets/models/cluster.py:29 assets/models/cmd_filter.py:48 #: assets/models/cluster.py:29 assets/models/cmd_filter.py:48
#: assets/models/cmd_filter.py:96 assets/models/domain.py:24 #: assets/models/cmd_filter.py:96 assets/models/domain.py:24
#: assets/models/domain.py:64 assets/models/group.py:23 #: assets/models/domain.py:64 assets/models/group.py:23
#: assets/models/label.py:23 ops/models/adhoc.py:38 orgs/models.py:15 #: assets/models/label.py:23 ops/models/adhoc.py:38 orgs/models.py:68
#: perms/models/base.py:93 rbac/models/role.py:37 settings/models.py:34 #: perms/models/base.py:93 rbac/models/role.py:37 settings/models.py:34
#: terminal/models/storage.py:26 terminal/models/terminal.py:114 #: terminal/models/storage.py:26 terminal/models/terminal.py:114
#: tickets/models/comment.py:24 tickets/models/ticket.py:154 #: tickets/models/comment.py:24 tickets/models/ticket.py:154
@ -89,8 +89,8 @@ msgstr "登录复核"
#: acls/models/login_acl.py:24 acls/models/login_asset_acl.py:20 #: acls/models/login_acl.py:24 acls/models/login_asset_acl.py:20
#: assets/models/cmd_filter.py:30 assets/models/label.py:15 audits/models.py:37 #: assets/models/cmd_filter.py:30 assets/models/label.py:15 audits/models.py:37
#: audits/models.py:60 audits/models.py:85 audits/serializers.py:100 #: audits/models.py:60 audits/models.py:85 audits/serializers.py:100
#: authentication/models.py:50 orgs/models.py:191 perms/models/base.py:84 #: authentication/models.py:50 orgs/models.py:214 perms/models/base.py:84
#: rbac/builtin.py:97 rbac/models/rolebinding.py:33 templates/index.html:78 #: rbac/builtin.py:98 rbac/models/rolebinding.py:39 templates/index.html:78
#: terminal/backends/command/models.py:19 #: terminal/backends/command/models.py:19
#: terminal/backends/command/serializers.py:12 terminal/models/session.py:42 #: terminal/backends/command/serializers.py:12 terminal/models/session.py:42
#: terminal/notifications.py:88 terminal/notifications.py:136 #: terminal/notifications.py:88 terminal/notifications.py:136
@ -375,7 +375,7 @@ msgstr "类型名称"
#: assets/models/group.py:22 assets/models/label.py:25 #: assets/models/group.py:22 assets/models/label.py:25
#: assets/serializers/account.py:18 common/db/models.py:113 #: assets/serializers/account.py:18 common/db/models.py:113
#: common/mixins/models.py:50 ops/models/adhoc.py:39 ops/models/command.py:30 #: common/mixins/models.py:50 ops/models/adhoc.py:39 ops/models/command.py:30
#: orgs/models.py:14 orgs/models.py:194 perms/models/base.py:92 #: orgs/models.py:67 orgs/models.py:217 perms/models/base.py:92
#: users/models/group.py:18 users/models/user.py:827 #: users/models/group.py:18 users/models/user.py:827
#: xpack/plugins/cloud/models.py:125 #: xpack/plugins/cloud/models.py:125
msgid "Date created" msgid "Date created"
@ -384,7 +384,7 @@ msgstr "创建日期"
#: applications/serializers/application.py:104 assets/models/base.py:182 #: applications/serializers/application.py:104 assets/models/base.py:182
#: assets/models/gathered_user.py:20 assets/serializers/account.py:21 #: assets/models/gathered_user.py:20 assets/serializers/account.py:21
#: common/db/models.py:114 common/mixins/models.py:51 ops/models/adhoc.py:40 #: common/db/models.py:114 common/mixins/models.py:51 ops/models/adhoc.py:40
#: orgs/models.py:195 #: orgs/models.py:218
msgid "Date updated" msgid "Date updated"
msgstr "更新日期" msgstr "更新日期"
@ -626,8 +626,8 @@ msgstr "标签管理"
#: assets/models/asset.py:229 assets/models/base.py:183 #: assets/models/asset.py:229 assets/models/base.py:183
#: assets/models/cluster.py:28 assets/models/cmd_filter.py:52 #: assets/models/cluster.py:28 assets/models/cmd_filter.py:52
#: assets/models/cmd_filter.py:99 assets/models/group.py:21 #: assets/models/cmd_filter.py:99 assets/models/group.py:21
#: common/db/models.py:111 common/mixins/models.py:49 orgs/models.py:13 #: common/db/models.py:111 common/mixins/models.py:49 orgs/models.py:66
#: orgs/models.py:196 perms/models/base.py:91 users/models/user.py:619 #: orgs/models.py:219 perms/models/base.py:91 users/models/user.py:619
#: users/serializers/group.py:33 #: users/serializers/group.py:33
#: xpack/plugins/change_auth_plan/models/base.py:48 #: xpack/plugins/change_auth_plan/models/base.py:48
#: xpack/plugins/cloud/models.py:122 xpack/plugins/gathered_user/models.py:30 #: xpack/plugins/cloud/models.py:122 xpack/plugins/gathered_user/models.py:30
@ -1255,6 +1255,7 @@ msgid "System user name"
msgstr "系统用户名称" msgstr "系统用户名称"
#: assets/serializers/system_user.py:282 orgs/mixins/serializers.py:26 #: assets/serializers/system_user.py:282 orgs/mixins/serializers.py:26
#: rbac/serializers/rolebinding.py:23
msgid "Org name" msgid "Org name"
msgstr "组织名称" msgstr "组织名称"
@ -1383,7 +1384,7 @@ msgstr "日志审计"
#: audits/models.py:27 audits/models.py:57 #: audits/models.py:27 audits/models.py:57
#: authentication/templates/authentication/_access_key_modal.html:65 #: authentication/templates/authentication/_access_key_modal.html:65
#: rbac/tree.py:161 users/templates/users/user_asset_permission.html:128 #: rbac/tree.py:160 users/templates/users/user_asset_permission.html:128
#: users/templates/users/user_database_app_permission.html:111 #: users/templates/users/user_database_app_permission.html:111
msgid "Delete" msgid "Delete"
msgstr "删除" msgstr "删除"
@ -1437,11 +1438,11 @@ msgstr "文件管理"
#: audits/models.py:55 #: audits/models.py:55
#: authentication/templates/authentication/_access_key_modal.html:22 #: authentication/templates/authentication/_access_key_modal.html:22
#: rbac/tree.py:158 #: rbac/tree.py:157
msgid "Create" msgid "Create"
msgstr "创建" msgstr "创建"
#: audits/models.py:56 rbac/tree.py:160 templates/_csv_import_export.html:18 #: audits/models.py:56 rbac/tree.py:159 templates/_csv_import_export.html:18
#: templates/_csv_update_modal.html:6 #: templates/_csv_update_modal.html:6
#: users/templates/users/user_asset_permission.html:127 #: users/templates/users/user_asset_permission.html:127
#: users/templates/users/user_database_app_permission.html:110 #: users/templates/users/user_database_app_permission.html:110
@ -1565,7 +1566,7 @@ msgstr "运行用户"
msgid "Run as display" msgid "Run as display"
msgstr "运行用户名称" msgstr "运行用户名称"
#: audits/serializers.py:102 rbac/serializers/rolebinding.py:22 #: audits/serializers.py:102 rbac/serializers/rolebinding.py:21
msgid "User display" msgid "User display"
msgstr "用户名称" msgstr "用户名称"
@ -2878,25 +2879,25 @@ msgstr "当前组织 ({}) 不能被删除"
msgid "The organization have resource ({}) cannot be deleted" msgid "The organization have resource ({}) cannot be deleted"
msgstr "组织存在资源 ({}) 不能被删除" msgstr "组织存在资源 ({}) 不能被删除"
#: orgs/apps.py:7 rbac/tree.py:111 #: orgs/apps.py:7 rbac/tree.py:110
msgid "App organizations" msgid "App organizations"
msgstr "组织管理" msgstr "组织管理"
#: orgs/mixins/models.py:46 orgs/mixins/serializers.py:25 orgs/models.py:27 #: orgs/mixins/models.py:46 orgs/mixins/serializers.py:25 orgs/models.py:80
#: orgs/models.py:188 rbac/const.py:7 rbac/models/rolebinding.py:40 #: orgs/models.py:211 rbac/const.py:7 rbac/models/rolebinding.py:46
#: rbac/serializers/rolebinding.py:40 tickets/serializers/ticket/ticket.py:77 #: rbac/serializers/rolebinding.py:40 tickets/serializers/ticket/ticket.py:77
msgid "Organization" msgid "Organization"
msgstr "组织" msgstr "组织"
#: orgs/models.py:21 #: orgs/models.py:74
msgid "GLOBAL" msgid "GLOBAL"
msgstr "全局组织" msgstr "全局组织"
#: orgs/models.py:29 #: orgs/models.py:82
msgid "Can view root org" msgid "Can view root org"
msgstr "可以查看全局组织" msgstr "可以查看全局组织"
#: orgs/models.py:193 rbac/models/role.py:46 rbac/models/rolebinding.py:36 #: orgs/models.py:216 rbac/models/role.py:46 rbac/models/rolebinding.py:42
#: users/models/user.py:584 users/templates/users/_select_user_modal.html:15 #: users/models/user.py:584 users/templates/users/_select_user_modal.html:15
msgid "Role" msgid "Role"
msgstr "角色" msgstr "角色"
@ -3121,7 +3122,7 @@ msgstr "角色已绑定用户,不能删除"
msgid "Internal role, can't be update" msgid "Internal role, can't be update"
msgstr "内部角色,不能更新" msgstr "内部角色,不能更新"
#: rbac/api/rolebinding.py:46 #: rbac/api/rolebinding.py:52
msgid "{} at least one system role" msgid "{} at least one system role"
msgstr "{} 至少有一个系统角色" msgstr "{} 至少有一个系统角色"
@ -3129,27 +3130,27 @@ msgstr "{} 至少有一个系统角色"
msgid "RBAC" msgid "RBAC"
msgstr "RBAC" msgstr "RBAC"
#: rbac/builtin.py:88 #: rbac/builtin.py:89
msgid "SystemAdmin" msgid "SystemAdmin"
msgstr "系统管理员" msgstr "系统管理员"
#: rbac/builtin.py:91 #: rbac/builtin.py:92
msgid "SystemAuditor" msgid "SystemAuditor"
msgstr "系统审计员" msgstr "系统审计员"
#: rbac/builtin.py:94 #: rbac/builtin.py:95
msgid "SystemComponent" msgid "SystemComponent"
msgstr "系统组件" msgstr "系统组件"
#: rbac/builtin.py:100 #: rbac/builtin.py:101
msgid "OrgAdmin" msgid "OrgAdmin"
msgstr "组织管理员" msgstr "组织管理员"
#: rbac/builtin.py:103 #: rbac/builtin.py:104
msgid "OrgAuditor" msgid "OrgAuditor"
msgstr "组织审计员" msgstr "组织审计员"
#: rbac/builtin.py:106 #: rbac/builtin.py:107
msgid "OrgUser" msgid "OrgUser"
msgstr "组织用户" msgstr "组织用户"
@ -3181,7 +3182,7 @@ msgstr "文件管理"
msgid "Permission" msgid "Permission"
msgstr "授权" msgstr "授权"
#: rbac/models/role.py:31 rbac/models/rolebinding.py:30 #: rbac/models/role.py:31 rbac/models/rolebinding.py:36
msgid "Scope" msgid "Scope"
msgstr "范围" msgstr "范围"
@ -3201,21 +3202,21 @@ msgstr "系统角色"
msgid "Organization role" msgid "Organization role"
msgstr "组织角色" msgstr "组织角色"
#: rbac/models/rolebinding.py:45 #: rbac/models/rolebinding.py:51
msgid "Role binding" msgid "Role binding"
msgstr "角色绑定" msgstr "角色绑定"
#: rbac/models/rolebinding.py:111 #: rbac/models/rolebinding.py:123
msgid "" msgid ""
"User last role in org, can not be delete, you can remove user from org " "User last role in org, can not be delete, you can remove user from org "
"instead" "instead"
msgstr "用户最后一个角色,不能删除,你可以将用户从组织移除" msgstr "用户最后一个角色,不能删除,你可以将用户从组织移除"
#: rbac/models/rolebinding.py:118 #: rbac/models/rolebinding.py:130
msgid "Organization role binding" msgid "Organization role binding"
msgstr "组织角色绑定" msgstr "组织角色绑定"
#: rbac/models/rolebinding.py:132 #: rbac/models/rolebinding.py:145
msgid "System role binding" msgid "System role binding"
msgstr "系统角色绑定" msgstr "系统角色绑定"
@ -3231,7 +3232,7 @@ msgstr "范围名称"
msgid "Display name" msgid "Display name"
msgstr "显示名称" msgstr "显示名称"
#: rbac/serializers/rolebinding.py:23 #: rbac/serializers/rolebinding.py:22
msgid "Role display" msgid "Role display"
msgstr "角色显示" msgstr "角色显示"
@ -3239,87 +3240,87 @@ msgstr "角色显示"
msgid "Has bound this role" msgid "Has bound this role"
msgstr "已经绑定" msgstr "已经绑定"
#: rbac/tree.py:17 rbac/tree.py:18 #: rbac/tree.py:16 rbac/tree.py:17
msgid "All permissions" msgid "All permissions"
msgstr "所有权限" msgstr "所有权限"
#: rbac/tree.py:24 #: rbac/tree.py:23
msgid "Console view" msgid "Console view"
msgstr "控制台" msgstr "控制台"
#: rbac/tree.py:25 #: rbac/tree.py:24
msgid "Workspace view" msgid "Workspace view"
msgstr "工作台" msgstr "工作台"
#: rbac/tree.py:26 #: rbac/tree.py:25
msgid "Audit view" msgid "Audit view"
msgstr "审计台" msgstr "审计台"
#: rbac/tree.py:27 settings/models.py:140 #: rbac/tree.py:26 settings/models.py:140
msgid "System setting" msgid "System setting"
msgstr "系统设置" msgstr "系统设置"
#: rbac/tree.py:28 #: rbac/tree.py:27
msgid "Other" msgid "Other"
msgstr "其它" msgstr "其它"
#: rbac/tree.py:36 #: rbac/tree.py:35
msgid "Accounts" msgid "Accounts"
msgstr "账号管理" msgstr "账号管理"
#: rbac/tree.py:40 #: rbac/tree.py:39
msgid "Session audits" msgid "Session audits"
msgstr "会话审计" msgstr "会话审计"
#: rbac/tree.py:50 #: rbac/tree.py:49
msgid "Cloud import" msgid "Cloud import"
msgstr "云同步" msgstr "云同步"
#: rbac/tree.py:51 #: rbac/tree.py:50
msgid "Backup account" msgid "Backup account"
msgstr "备份账号" msgstr "备份账号"
#: rbac/tree.py:52 #: rbac/tree.py:51
msgid "Gather account" msgid "Gather account"
msgstr "收集账号" msgstr "收集账号"
#: rbac/tree.py:53 #: rbac/tree.py:52
msgid "App change auth" msgid "App change auth"
msgstr "应用改密" msgstr "应用改密"
#: rbac/tree.py:54 #: rbac/tree.py:53
msgid "Asset change auth" msgid "Asset change auth"
msgstr "资产改密" msgstr "资产改密"
#: rbac/tree.py:55 #: rbac/tree.py:54
msgid "Terminal setting" msgid "Terminal setting"
msgstr "终端设置" msgstr "终端设置"
#: rbac/tree.py:56 #: rbac/tree.py:55
msgid "My assets" msgid "My assets"
msgstr "我的资产" msgstr "我的资产"
#: rbac/tree.py:57 #: rbac/tree.py:56
msgid "My apps" msgid "My apps"
msgstr "我的应用" msgstr "我的应用"
#: rbac/tree.py:112 #: rbac/tree.py:111
msgid "Ticket comment" msgid "Ticket comment"
msgstr "工单评论" msgstr "工单评论"
#: rbac/tree.py:113 tickets/models/ticket.py:163 #: rbac/tree.py:112 tickets/models/ticket.py:163
msgid "Ticket" msgid "Ticket"
msgstr "工单管理" msgstr "工单管理"
#: rbac/tree.py:114 #: rbac/tree.py:113
msgid "Common setting" msgid "Common setting"
msgstr "一般设置" msgstr "一般设置"
#: rbac/tree.py:115 #: rbac/tree.py:114
msgid "Execute batch command" msgid "Execute batch command"
msgstr "执行批量命令" msgstr "执行批量命令"
#: rbac/tree.py:159 #: rbac/tree.py:158
msgid "View" msgid "View"
msgstr "查看" msgstr "查看"
@ -6839,6 +6840,21 @@ msgstr "旗舰版"
msgid "Community edition" msgid "Community edition"
msgstr "社区版" msgstr "社区版"
#, fuzzy
#~| msgid "Create"
#~ msgid "create"
#~ msgstr "创建"
#, fuzzy
#~| msgid "Update"
#~ msgid "update"
#~ msgstr "更新"
#, fuzzy
#~| msgid "Delete"
#~ msgid "delete"
#~ msgstr "删除"
#~ msgid "Can connect my assets" #~ msgid "Can connect my assets"
#~ msgstr "可以连接我的资产" #~ msgstr "可以连接我的资产"

View File

@ -12,6 +12,7 @@ user_perms = (
('assets', 'systemuser', 'match', 'systemuser'), ('assets', 'systemuser', 'match', 'systemuser'),
('assets', 'node', 'match', 'node'), ('assets', 'node', 'match', 'node'),
('ops', 'commandexecution', 'add', 'commandexecution'), ('ops', 'commandexecution', 'add', 'commandexecution'),
('authentication', 'connectiontoken', 'add', 'connectiontoken'),
) )
auditor_perms = user_perms + ( auditor_perms = user_perms + (

View File

@ -2,11 +2,10 @@
from collections import defaultdict from collections import defaultdict
from typing import Callable from typing import Callable
from django.utils.translation import gettext_lazy as _, gettext from django.utils.translation import gettext_lazy as _, gettext, get_language
from django.conf import settings from django.conf import settings
from django.apps import apps from django.apps import apps
from django.db.models import F, Count from django.db.models import F, Count
from django.utils.translation import ugettext
from common.tree import TreeNode from common.tree import TreeNode
from .models import Permission, ContentType from .models import Permission, ContentType
@ -155,10 +154,10 @@ def sort_nodes(node):
class PermissionTreeUtil: class PermissionTreeUtil:
get_permissions: Callable get_permissions: Callable
action_mapper = { action_mapper = {
'add': ugettext('Create'), 'add': _('Create'),
'view': ugettext('View'), 'view': _('View'),
'change': ugettext('Update'), 'change': _('Update'),
'delete': ugettext('Delete') 'delete': _('Delete')
} }
action_icon = { action_icon = {
'add': 'add', 'add': 'add',
@ -178,6 +177,7 @@ class PermissionTreeUtil:
self.check_disabled = check_disabled self.check_disabled = check_disabled
self.total_counts = defaultdict(int) self.total_counts = defaultdict(int)
self.checked_counts = defaultdict(int) self.checked_counts = defaultdict(int)
self.lang = get_language()
@staticmethod @staticmethod
def prefetch_permissions(perms): def prefetch_permissions(perms):
@ -288,12 +288,18 @@ class PermissionTreeUtil:
return name, icon return name, icon
app_model = '%s.%s' % (p.content_type.app_label, resource) app_model = '%s.%s' % (p.content_type.app_label, resource)
if action in self.action_mapper and app_model in content_types_name_mapper: if self.lang == 'en':
name = p.name
# 因为默认的权限位是没有翻译的,所以我们要用 action + resource name 去拼
elif action in self.action_mapper and app_model in content_types_name_mapper:
action_name = self.action_mapper[action] action_name = self.action_mapper[action]
name = action_name + content_types_name_mapper[app_model] resource_name = content_types_name_mapper[app_model]
sep = ''
name = '{}{}{}'.format(action_name, sep, resource_name)
# 手动创建的 permission
else: else:
name = gettext(p.name) name = gettext(p.name)
name = name.replace('Can ', '').replace('可以', '') name = name.replace('Can ', '').replace('可以', '').capitalize()
return name, icon return name, icon
def _create_perms_nodes(self): def _create_perms_nodes(self):