perf: yaml 文件支持 i18n

This commit is contained in:
ibuler
2023-04-20 11:13:28 +08:00
parent 11ad6ab273
commit 6b3665e8d0
8 changed files with 84 additions and 14 deletions

View File

@@ -1,4 +0,0 @@
- zh:
display_name: Chrome 浏览器
comment: 浏览器打开 URL 页面地址

View File

@@ -1,7 +1,7 @@
name: chrome
display_name: Chrome Browser
display_name: "{{ 'Chrome Browser' | trans }}"
version: 0.2
comment: Chrome Browser Open URL Page Address
comment: "{{ 'Chrome Browser Open URL Page Address' | trans }}"
author: JumpServer Team
exec_type: python
update_policy: always
@@ -10,3 +10,14 @@ tags:
- web
protocols:
- http
i18n:
en:
Chrome Browser: Chrome Browser
Chrome Browser Open URL Page Address: Chrome Browser Open URL Page Address
zh:
Chrome Browser: Chrome 浏览器
Chrome Browser Open URL Page Address: Chrome 浏览器打开网页地址
ja:
Chrome Browser: Chrome ブラウザ
Chrome Browser Open URL Page Address: Chrome ブラウザでウェブページを開く

View File

@@ -1,6 +1,6 @@
name: dbeaver
display_name: DBeaver Community
comment: Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases.
display_name: "{{ 'DBeaver Community' | trans }}"
comment: "{{ 'Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases.' | trans }}"
version: 0.1
exec_type: python
author: JumpServer Team
@@ -14,3 +14,14 @@ protocols:
- postgresql
- sqlserver
- oracle
i18n:
en:
DBeaver Community: DBeaver Community
Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases.: Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases.
zh:
DBeaver Community: DBeaver 社区版
Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases.: 免费的多平台数据库工具,供开发人员、数据库管理员、分析师和所有需要使用数据库的人使用。
ja:
DBeaver Community: DBeaver コミュニティ
Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases.: 開発者、データベース管理者、分析家、およびデータベースを使用する必要があるすべての人のための無料のマルチプラットフォームデータベースツール。

View File

@@ -12,6 +12,7 @@ from rest_framework.serializers import ValidationError
from common.db.models import JMSBaseModel
from common.utils import lazyproperty, get_logger
from common.utils.yml import yaml_load_with_i18n
logger = get_logger(__name__)
@@ -76,14 +77,14 @@ class Applet(JMSBaseModel):
@staticmethod
def validate_pkg(d):
files = ['manifest.yml', 'icon.png', 'i18n.yml', 'setup.yml']
files = ['manifest.yml', 'icon.png', 'setup.yml']
for name in files:
path = os.path.join(d, name)
if not os.path.exists(path):
raise ValidationError({'error': _('Applet pkg not valid, Missing file {}').format(name)})
with open(os.path.join(d, 'manifest.yml')) as f:
manifest = yaml.safe_load(f)
manifest = yaml_load_with_i18n(f)
if not manifest.get('name', ''):
raise ValidationError({'error': 'Missing name in manifest.yml'})