Skip to content

Commit 9164dd9

Browse files
committed
add english ui4
1 parent 2fd537a commit 9164dd9

File tree

8 files changed

+74
-14
lines changed

8 files changed

+74
-14
lines changed

locale/en/LC_MESSAGES/django.mo

28 Bytes
Binary file not shown.

locale/en/LC_MESSAGES/django.po

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2023-11-26 11:50+0800\n"
11-
"PO-Revision-Date: 2023-11-26 11:54+0800\n"
10+
"POT-Creation-Date: 2023-11-26 16:13+0800\n"
11+
"PO-Revision-Date: 2023-11-26 16:14+0800\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
1414
"Language: en\n"
@@ -329,12 +329,12 @@ msgid "Search History"
329329
msgstr "Search History"
330330

331331
#: .\mdict\templates\mdict\mdict-modal-list.html:15
332-
msgid "Disable Index"
333-
msgstr "Disable Index"
332+
msgid "Enable Disable Index"
333+
msgstr "Enable/Disable Index"
334334

335335
#: .\mdict\templates\mdict\mdict-modal-list.html:22
336-
msgid "Disable All"
337-
msgstr "Disable All"
336+
msgid "Enable Disable All"
337+
msgstr "Enable/Disable All"
338338

339339
#: .\mdict\templates\mdict\mdict-navbar.html:43
340340
msgid "Full"
@@ -476,3 +476,6 @@ msgstr "English"
476476
#: .\mysite\settings.py:139
477477
msgid "Chinese Simplified"
478478
msgstr "Chinese Simplified"
479+
480+
#~ msgid "Disable Index"
481+
#~ msgstr "Disable Index"

locale/zh_Hans/LC_MESSAGES/django.mo

28 Bytes
Binary file not shown.

locale/zh_Hans/LC_MESSAGES/django.po

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2023-11-26 11:50+0800\n"
11-
"PO-Revision-Date: 2023-11-26 12:02+0800\n"
10+
"POT-Creation-Date: 2023-11-26 16:13+0800\n"
11+
"PO-Revision-Date: 2023-11-26 16:14+0800\n"
1212
"Last-Translator: \n"
1313
"Language-Team: \n"
1414
"Language: zh\n"
@@ -328,12 +328,12 @@ msgid "Search History"
328328
msgstr "查询历史"
329329

330330
#: .\mdict\templates\mdict\mdict-modal-list.html:15
331-
msgid "Disable Index"
332-
msgstr "关闭索引"
331+
msgid "Enable Disable Index"
332+
msgstr "启用/停止索引"
333333

334334
#: .\mdict\templates\mdict\mdict-modal-list.html:22
335-
msgid "Disable All"
336-
msgstr "全部关闭"
335+
msgid "Enable Disable All"
336+
msgstr "全部启用/停止"
337337

338338
#: .\mdict\templates\mdict\mdict-navbar.html:43
339339
msgid "Full"
@@ -476,6 +476,9 @@ msgstr "英语"
476476
msgid "Chinese Simplified"
477477
msgstr "简体中文"
478478

479+
#~ msgid "Disable Index"
480+
#~ msgstr "关闭索引"
481+
479482
#~ msgid "Dictionary Online"
480483
#~ msgstr "在线词典"
481484

mdict/static/mdict/js/mdict_base.js

+18
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ function init_common_config(){//这里后面改成从后台取数据
402402
var i=1;
403403
var col_num=7;
404404

405+
retrieveconfigdict(false, function(){});
406+
405407
for(var key in common_config){
406408
var c_id="config-"+key;
407409
var c_text=common_config[key];
@@ -449,6 +451,22 @@ function init_common_config(){//这里后面改成从后台取数据
449451

450452
}
451453

454+
function retrieveconfigdict(async, func){
455+
$.ajax({
456+
url:"/mdict/retrieveconfigdict/",
457+
contentType:'json',
458+
type:'GET',
459+
async:async,
460+
success:function(data){
461+
var configdict=$.parseJSON(data);
462+
common_config = configdict;
463+
},
464+
error:function(jqXHR,textStatus,errorThrown){
465+
alert(jqXHR.responseText);
466+
},
467+
});
468+
}
469+
452470
function retrieveconfig(async,func){
453471
$.ajax({
454472
url:"/mdict/retrieveconfig/",

mdict/templates/mdict/mdict-modal-list.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
{% if type == 'es' %}
1313
<div class="d-grid gap-2">
1414
<button class="btn btn-outline-primary" type="button" id="open-close-index">
15-
{% trans "Disable Index" %}
15+
{% trans "Enable Disable Index" %}
1616
</button>
1717
</div>
1818
{% endif %}
1919
<br/>
2020
<div id='enable-all-dic' class="form-checkbox" style="display:inline;">
2121
<input class="form-check-input" type="checkbox" id="enableAllCheck" onchange="set_all_mdict_enable(this)">
22-
<label class="form-check-label mdict-list-mark" for="enableAllCheck" style="margin:0px 0px 10px 5px"><b>{% trans "Disable All" %}<span id="dic_num"></span></b></label>
22+
<label class="form-check-label mdict-list-mark" for="enableAllCheck" style="margin:0px 0px 10px 5px"><b>{% trans "Enable Disable All" %}&nbsp▷&nbsp<span id="dic_num"></span></b></label>
2323
{% if type == 'es' %}
2424
<span id="init-index-spinner" class="spinner-border text-primary spinner-grow-sm" role="status" style="display:none;"></span>
2525
{% endif %}

mdict/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
path('getdicgroup/', views.get_dic_group),
4343
path('setmdictenable/', views.set_mdict_enable),
4444
path('retrieveconfig/', views.retrieve_config),
45+
path('retrieveconfigdict/', views.retrieve_config_dict),
4546
path('saveconfig/', views.save_config),
4647
path('bujian/', views.bujianjiansuo),
4748
path('es/', views.es_index),

mdict/views.py

+35
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.http import HttpResponse
1111
from django.shortcuts import render
1212
from django.contrib.auth.decorators import login_required
13+
from django.utils.translation import get_language
1314

1415
from rest_framework import viewsets
1516
from rest_framework.decorators import action, api_view, authentication_classes, permission_classes
@@ -56,6 +57,8 @@
5657
else:
5758
xapian = None
5859

60+
main_cur_language = 'en'
61+
5962
init_database()
6063

6164
reg = r'[ _=,.;:!?@%&#~`()\[\]<>{}/\\\$\+\-\*\^\'"\t]'
@@ -1321,18 +1324,24 @@ def get_dic_info(request):
13211324

13221325

13231326
def mdict_index(request):
1327+
global main_cur_language
1328+
main_cur_language = get_language()
13241329
query = request.GET.get('query', '')
13251330
is_mb = is_mobile(request)
13261331
return render(request, 'mdict/mdict-index.html', {'query': query, 'is_mobile': is_mb, 'type': 'index'})
13271332

13281333

13291334
def mdict_index_simple(request):
1335+
global main_cur_language
1336+
main_cur_language = get_language()
13301337
query = request.GET.get('query', '')
13311338
is_mb = is_mobile(request)
13321339
return render(request, 'mdict/mdict-index-simple.html', {'query': query, 'is_mobile': is_mb, 'type': 'index'})
13331340

13341341

13351342
def mdict_index_simple2(request):
1343+
global main_cur_language
1344+
main_cur_language = get_language()
13361345
query = request.GET.get('query', '')
13371346
is_mb = is_mobile(request)
13381347
return render(request, 'mdict/mdict-index-simple2.html', {'query': query, 'is_mobile': is_mb, 'type': 'simple2'})
@@ -1936,12 +1945,16 @@ def getwordlist(request):
19361945

19371946

19381947
def es_index(request):
1948+
global main_cur_language
1949+
main_cur_language = get_language()
19391950
query = request.GET.get('query', '')
19401951
is_mb = is_mobile(request)
19411952
return render(request, 'mdict/mdict-es-index.html', {'query': query, 'type': 'es', 'is_mobile': is_mb})
19421953

19431954

19441955
def mdict_dic(request, *args):
1956+
global main_cur_language
1957+
main_cur_language = get_language()
19451958
# dic_pk = int(request.GET.get('dic_pk', -1))
19461959
dic_pk = args[0]
19471960

@@ -2172,6 +2185,28 @@ def retrieve_config(request):
21722185
return HttpResponse(json.dumps(r_config))
21732186

21742187

2188+
def retrieve_config_dict(request):
2189+
global main_cur_language
2190+
if main_cur_language == 'zh-hans':
2191+
r_config = {'force-refresh': '强制刷新', 'st-enable': '繁简转换', 'chaizi-enable': '拆字反查',
2192+
'fh-char-enable': '英文全角转半角',
2193+
'kana-enable': '平片假名转换', 'romaji-enable': '罗马字假名转换', 'link-new-label': '跳转新标签页',
2194+
'force-font': '强制全宋体',
2195+
'card-show': '展开多个词典', 'select-btn-enable': '启用查询菜单', 'new-label-link': '新标签页正查',
2196+
'fixed-height': '固定高度',
2197+
'magnifier-enable': '启用放大镜', 'hide-bottom-bar': '隐藏底部栏'}
2198+
else:
2199+
r_config = {'force-refresh': 'Force Refresh', 'st-enable': 'Chinese Simplified/Traditional', 'chaizi-enable': '拆字反查',
2200+
'fh-char-enable': 'Full-width to Half-width',
2201+
'kana-enable': 'Katakana/Hiragana', 'romaji-enable': 'Romaji Convert', 'link-new-label': 'Open Link in New Tab',
2202+
'force-font': 'Force 全宋体',
2203+
'card-show': 'Show Multiple Tabs', 'select-btn-enable': 'Enable Select Menu', 'new-label-link': 'New Tab in Search Page',
2204+
'fixed-height': 'Iframe Fixed Height',
2205+
'magnifier-enable': 'Enable Magnifier', 'hide-bottom-bar': 'Hide Bottom Bar'}
2206+
2207+
return HttpResponse(json.dumps(r_config))
2208+
2209+
21752210
def save_config(request):
21762211
config_dict = {}
21772212

0 commit comments

Comments
 (0)