mirror of https://github.com/jumpserver/jumpserver
perf: 统一翻译
parent
2b15fc5e8b
commit
c06c68d5da
|
@ -298,7 +298,7 @@ USE_TZ = True
|
||||||
|
|
||||||
# I18N translation
|
# I18N translation
|
||||||
LOCALE_PATHS = [
|
LOCALE_PATHS = [
|
||||||
os.path.join(BASE_DIR, 'locale'),
|
os.path.join(BASE_DIR, 'locale', 'core'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
@ -323,7 +323,6 @@ PRIVATE_STORAGE_SERVER = 'nginx'
|
||||||
if DEBUG_DEV:
|
if DEBUG_DEV:
|
||||||
PRIVATE_STORAGE_SERVER = 'django'
|
PRIVATE_STORAGE_SERVER = 'django'
|
||||||
|
|
||||||
|
|
||||||
# Use django-bootstrap-form to format template, input max width arg
|
# Use django-bootstrap-form to format template, input max width arg
|
||||||
# BOOTSTRAP_COLUMN_COUNT = 11
|
# BOOTSTRAP_COLUMN_COUNT = 11
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -2,6 +2,7 @@ from .chat import *
|
||||||
from .dingtalk import *
|
from .dingtalk import *
|
||||||
from .email import *
|
from .email import *
|
||||||
from .feishu import *
|
from .feishu import *
|
||||||
|
from .i18n import *
|
||||||
from .ldap import *
|
from .ldap import *
|
||||||
from .public import *
|
from .public import *
|
||||||
from .security import *
|
from .security import *
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.utils._os import safe_join
|
||||||
|
from rest_framework.generics import RetrieveAPIView
|
||||||
|
from rest_framework.permissions import AllowAny
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
|
||||||
|
class ComponentI18nApi(RetrieveAPIView):
|
||||||
|
base_path = 'locale'
|
||||||
|
permission_classes = [AllowAny]
|
||||||
|
|
||||||
|
def get_path(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def head(self, request, *args, **kwargs):
|
||||||
|
return Response()
|
||||||
|
|
||||||
|
def retrieve(self, request, *args, **kwargs):
|
||||||
|
name = kwargs.get('name')
|
||||||
|
component_dir = safe_join(settings.APPS_DIR, 'locale', name)
|
||||||
|
lang = request.query_params.get('lang')
|
||||||
|
files = os.listdir(component_dir)
|
||||||
|
data = {}
|
||||||
|
for file in files:
|
||||||
|
if not file.endswith('.json'):
|
||||||
|
continue
|
||||||
|
_lang = file.split('.')[0]
|
||||||
|
with open(safe_join(component_dir, file), 'r') as f:
|
||||||
|
data[_lang] = json.load(f)
|
||||||
|
if lang:
|
||||||
|
data = {lang: data.get(lang) or {}}
|
||||||
|
return Response(data)
|
|
@ -30,6 +30,7 @@ urlpatterns = [
|
||||||
path('public/', api.PublicSettingApi.as_view(), name='public-setting'),
|
path('public/', api.PublicSettingApi.as_view(), name='public-setting'),
|
||||||
path('public/open/', api.OpenPublicSettingApi.as_view(), name='open-public-setting'),
|
path('public/open/', api.OpenPublicSettingApi.as_view(), name='open-public-setting'),
|
||||||
path('server-info/', api.ServerInfoApi.as_view(), name='server-info'),
|
path('server-info/', api.ServerInfoApi.as_view(), name='server-info'),
|
||||||
|
path('i18n/<str:name>/', api.ComponentI18nApi.as_view(), name='i18n-data'),
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += router.urls
|
urlpatterns += router.urls
|
||||||
|
|
Loading…
Reference in New Issue