Merge pull request #10272 from jumpserver/pr@dev@perf_asset_task_i18n

perf: 优化资产任务的 i18n
pull/10276/head
老广 2023-04-20 14:45:24 +08:00 committed by GitHub
commit 75724cbddb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 79 additions and 17 deletions

View File

@ -1,6 +1,11 @@
id: gather_facts_mongodb
name: Gather facts from MongoDB
name: "{{ 'Gather facts from MongoDB' | trans }}"
category: database
type:
- mongodb
method: gather_facts
i18n:
Gather facts from MongoDB:
zh: 从 MongoDB 获取信息
en: Gather facts from MongoDB
ja: MongoDBから事実を取得する

View File

@ -1,7 +1,12 @@
id: gather_facts_mysql
name: Gather facts from MySQL
name: "{{ 'Gather facts from MySQL' | trans }}"
category: database
type:
- mysql
- mariadb
method: gather_facts
i18n:
Gather facts from MySQL:
zh: 从 MySQL 获取信息
en: Gather facts from MySQL
ja: MySQLから事実を取得する

View File

@ -1,6 +1,11 @@
id: gather_facts_oracle
name: Gather facts from Oracle
name: "{{ 'Gather facts from Oracle' | trans }}"
category: database
type:
- oracle
method: gather_facts
i18n:
Gather facts from Oracle:
zh: 从 Oracle 获取信息
en: Gather facts from Oracle
ja: Oracleから事実を取得する

View File

@ -1,6 +1,11 @@
id: gather_facts_postgresql
name: Gather facts for PostgreSQL
name: "{{ 'Gather facts for PostgreSQL' | trans }}"
category: database
type:
- postgresql
method: gather_facts
i18n:
Gather facts for PostgreSQL:
zh: 从 PostgreSQL 获取信息
en: Gather facts for PostgreSQL
ja: PostgreSQLから事実を取得する

View File

@ -1,7 +1,12 @@
id: gather_facts_posix
name: Gather posix facts
name: "{{ 'Gather posix facts' | trans }}"
category: host
type:
- linux
- unix
method: gather_facts
i18n:
Gather posix facts:
zh: 从 Posix 主机获取信息
en: Gather posix facts
ja: Posixから事実を取得する

View File

@ -1,7 +1,12 @@
id: gather_facts_windows
name: Gather facts windows
name: "{{ 'Gather facts windows' | trans }}"
version: 1
method: gather_facts
category: host
type:
- windows
i18n:
Gather facts windows:
zh: 从 Windows 获取信息
en: Gather facts windows
ja: Windowsから事実を取得する

View File

@ -1,6 +1,11 @@
id: mongodb_ping
name: Ping MongoDB
name: "{{ 'Ping MongoDB' | trans }}"
category: database
type:
- mongodb
method: ping
i18n:
Ping MongoDB:
zh: 测试 MongoDB 可连接性
en: Ping MongoDB
ja: MongoDBにPingする

View File

@ -1,7 +1,12 @@
id: mysql_ping
name: Ping MySQL
name: "{{ 'Ping MySQL' | trans }}"
category: database
type:
- mysql
- mariadb
method: ping
i18n:
Ping MySQL:
zh: 测试 MySQL 可连接性
en: Ping MySQL
ja: MySQLにPingする

View File

@ -1,6 +1,11 @@
id: oracle_ping
name: Ping Oracle
name: "{{ 'Ping Oracle' | trans }}"
category: database
type:
- oracle
method: ping
i18n:
Ping Oracle:
zh: 测试 Oracle 可连接性
en: Ping Oracle
ja: OracleにPingする

View File

@ -1,6 +1,11 @@
id: ping_postgresql
name: Ping PostgreSQL
name: "{{ 'Ping PostgreSQL' | trans }}"
category: database
type:
- postgresql
method: ping
i18n:
Ping PostgreSQL:
zh: 测试 PostgreSQL 可连接性
en: Ping PostgreSQL
ja: PostgreSQLにPingする

View File

@ -1,6 +1,11 @@
id: sqlserver_ping
name: Ping SQLServer
name: "{{ 'Ping SQLServer' | trans }}"
category: database
type:
- sqlserver
method: ping
i18n:
Ping SQLServer:
zh: 测试 SQLServer 可连接性
en: Ping SQLServer
ja: SQLServerにPingする

View File

@ -8,6 +8,6 @@ method: ping
i18n:
Posix ping:
zh: Posix ping
zh: 测试 Posix 可连接性
en: Posix ping
ja: Posix ピング

View File

@ -1,7 +1,12 @@
id: win_ping
name: Windows ping
name: "{{ 'Windows ping' | trans }}"
version: 1
method: ping
category: host
type:
- windows
i18n:
Windows ping:
zh: 测试 Windows 可连接性
en: Windows ping
ja: Windows ピング

View File

@ -1,12 +1,12 @@
import io
import yaml
from django.utils.translation import get_language
from django.conf import settings
from jinja2 import Environment
def translate(i18n, key):
lang = get_language()[:2]
def translate(key, i18n):
lang = settings.LANGUAGE_CODE[:2]
lang_data = i18n.get(key, {})
return lang_data.get(lang, key)
@ -18,7 +18,7 @@ def yaml_load_with_i18n(stream):
i18n = yaml_data.get('i18n', {})
env = Environment()
env.filters['trans'] = lambda key: translate(i18n, key)
env.filters['trans'] = lambda key: translate(key, i18n)
template = env.from_string(ori_text)
yaml_data = template.render()
yaml_f = io.StringIO(yaml_data)

View File

@ -146,6 +146,8 @@ only_system_permissions = (
('authentication', '*', '*', '*'),
('tickets', '*', '*', '*'),
('orgs', 'organization', 'view', 'rootorg'),
('terminal', 'applet', '*', '*'),
('terminal', 'applethost', '*', '*'),
)
only_org_permissions = (