2019-02-10 11:44:25 +08:00
|
|
|
|
# -*- coding:utf-8 -*-
|
2018-07-01 10:55:30 +08:00
|
|
|
|
#
|
2018-07-27 17:57:00 +08:00
|
|
|
|
# Copyright (C) 2018 sthoo <sth201807@gmail.com>
|
2018-07-01 10:55:30 +08:00
|
|
|
|
#
|
|
|
|
|
|
# Support: Report an issue at https://github.com/sth2018/FastWordQuery/issues
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
|
# any later version; http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
#
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
2023-01-28 00:36:43 +08:00
|
|
|
|
from anki.lang import current_lang
|
2019-02-10 11:44:25 +08:00
|
|
|
|
|
2018-07-30 16:00:47 +08:00
|
|
|
|
try:
|
2019-02-10 11:44:25 +08:00
|
|
|
|
basestring
|
2018-07-30 16:00:47 +08:00
|
|
|
|
except NameError:
|
2019-02-10 11:44:25 +08:00
|
|
|
|
basestring = str
|
2018-07-01 10:55:30 +08:00
|
|
|
|
|
2018-07-06 20:56:20 +08:00
|
|
|
|
__all__ = ['_', '_cl', '_sl']
|
|
|
|
|
|
|
2023-01-31 11:50:28 +08:00
|
|
|
|
# Language Define, [Key, zh-CN, en]
|
2018-07-14 15:24:21 +08:00
|
|
|
|
_arr = [
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['CHECK_FILENAME_LABEL', u'使用文件名作为标签', u'Use the Filename as Label'],
|
2018-07-10 23:51:07 +08:00
|
|
|
|
['EXPORT_MEDIA', u'导出媒体文件', u'Export Media Files'],
|
|
|
|
|
|
['DICTS_FOLDERS', u'字典文件夹', u'Dictionary Folder'],
|
|
|
|
|
|
['CHOOSE_NOTE_TYPES', u'选择笔记类型', u'Choose Note Type'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['CURRENT_NOTE_TYPE', u'当前类型', u'Current type'],
|
|
|
|
|
|
['MDX_SERVER', u'MDX服务器', u'MDX server'],
|
|
|
|
|
|
['USE_DICTIONARY', u'使用字典', u'Use dict'],
|
|
|
|
|
|
['UPDATED', u'更新', u'Updated'],
|
|
|
|
|
|
['CARDS', u'卡片', u'Cards'],
|
|
|
|
|
|
['FAILURE', u'失败', u'Failure'],
|
|
|
|
|
|
['SUCCESS', u'成功', u'Success'],
|
|
|
|
|
|
['QUERIED', u'查询', u'Queried'],
|
|
|
|
|
|
['FIELDS', u'字段', u'Fields'],
|
|
|
|
|
|
['WORDS', u'单词', u'Words'],
|
2019-02-10 11:44:25 +08:00
|
|
|
|
['NOT_DICT_FIELD', u'忽略', u'Ignore'], # 不是字典字段
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['NOTE_TYPE_FIELDS', u'<b>笔记字段</b>', u'<b>Note Fields</b>'],
|
2018-07-10 23:51:07 +08:00
|
|
|
|
['DICTS', u'<b>字典</b>', u'<b>Dictionary</b>'],
|
|
|
|
|
|
['DICT_FIELDS', u'<b>字典字段</b>', u'<b>Fields</b>'],
|
2019-02-10 11:44:25 +08:00
|
|
|
|
[
|
|
|
|
|
|
'RADIOS_DESC', u'<b>单选框选中为待查询单词字段</b>',
|
|
|
|
|
|
u'<b> Select the field to be queried with single selection.</b>'
|
|
|
|
|
|
],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['NO_QUERY_WORD', u'查询字段无单词', u'The query field is empty'],
|
2019-02-10 11:44:25 +08:00
|
|
|
|
[
|
|
|
|
|
|
'CSS_NOT_FOUND', u'没有找到CSS文件,请手动选择',
|
|
|
|
|
|
u'No CSS file found, please select one manually.'
|
|
|
|
|
|
],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['ABOUT', u'关于', u'About'],
|
2018-07-08 00:54:05 +08:00
|
|
|
|
['REPOSITORY', u'项目地址', u'Project Repo'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['FEEDBACK', u'反馈', u'Feedback'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['VERSION', u'版本', u'Current Version'],
|
|
|
|
|
|
['LATEST_VERSION', u'已经是最新版本.', u'You are using the lastest version.'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['ABNORMAL_VERSION', u'当前版本异常.', u'The current version is abnormal.'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['CHECK_FAILURE', u'版本检查失败.', u'Version check failed.'],
|
|
|
|
|
|
['NEW_VERSION', u'检查到新版本:', u'New version available:'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['UPDATE', u'更新', u'Update'],
|
2018-07-31 15:46:03 +08:00
|
|
|
|
['AUTO_UPDATE', u'自动检测新版本', u'Auto check new version'],
|
2018-09-12 12:28:50 +08:00
|
|
|
|
['CHECK_UPDATE', u'检测更新', u'Check Update'],
|
2019-02-10 11:44:25 +08:00
|
|
|
|
[
|
|
|
|
|
|
'IGNORE_MDX_WORDCASE', u'忽略本地词典单词大小写',
|
|
|
|
|
|
u'Ignore MDX dictionary word case'
|
|
|
|
|
|
],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['FORCE_UPDATE', u'强制更新字段', u'Forced Updates of all fields'],
|
2018-07-11 22:09:17 +08:00
|
|
|
|
['IGNORE_ACCENTS', u'忽略声调', u'Ignore Accents'],
|
2018-07-28 14:16:18 +08:00
|
|
|
|
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['SKIPED', u'略过', 'Skipped'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['SETTINGS', u'参数', u'Settings'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['THREAD_NUMBER', u'线程数', u'Number of Threads'],
|
2018-07-09 14:14:52 +08:00
|
|
|
|
['INITLIZING_DICT', u'初始化词典...', u'Initlizing Dictionary...'],
|
2019-02-10 11:44:25 +08:00
|
|
|
|
[
|
|
|
|
|
|
'PLS_SET_DICTIONARY_FIELDS', u'请设置字典和字段',
|
|
|
|
|
|
u'Please set the dictionary and fields.'
|
|
|
|
|
|
],
|
2018-08-09 20:10:29 +08:00
|
|
|
|
['CONFIG_INDEX', u'配置 %s', u'Config %s'],
|
2018-08-10 15:08:01 +08:00
|
|
|
|
['SELECT_ALL', u'全选', u'All'],
|
2018-08-15 00:46:46 +08:00
|
|
|
|
['DICTS_NAME', u'字典名称', u'Dictionary Name'],
|
|
|
|
|
|
['EDIT', u'编辑', u'Edit'],
|
2018-08-26 22:48:24 +08:00
|
|
|
|
['QUERY', u'查询', u'Query'],
|
|
|
|
|
|
['QUERY_SELECTED', u'查询选中项', u'Query Selected'],
|
|
|
|
|
|
['ALL_FIELDS', u'所有字段', u'All Fields'],
|
|
|
|
|
|
['CURRENT_FIELDS', u'当前字段', u'Current Fields'],
|
|
|
|
|
|
['OPTIONS', u'选项', u'Options'],
|
2018-08-28 16:59:57 +08:00
|
|
|
|
['CLOZE_WORD', u'单词填空', u'Cloze word'],
|
2018-11-05 22:47:30 +08:00
|
|
|
|
['CLOZE_WORD_FORMAT', '单词填空格式', 'Cloze word formater'],
|
2019-06-16 01:39:20 +08:00
|
|
|
|
['SOUND_FORMAT', '发音格式化', 'Sound formater'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['BRE_PRON', u'英式发音', u'British Pronunciation'],
|
|
|
|
|
|
['AME_PRON', u'美式发音', u'American Pronunciation'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['PRON', u'发音', u'Audio Pronunciation'],
|
|
|
|
|
|
['EXAMPLE', u'例句', u'Examples'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
['TRANS', u'翻译', u'Translation'],
|
|
|
|
|
|
['DEF', u'释义', u'Definition'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['PHON', u'音标', u'Phonetic Symbols'],
|
|
|
|
|
|
['BRE_PHON', u'英式音标', u'Phonetic Symbols (UK)'],
|
2019-04-06 11:04:58 +08:00
|
|
|
|
['BRE_PHON_NO_PREFIX', u'英式音标无前缀', u'Phonetic Symbols (UK) no prefix'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['AME_PHON', u'美式音标', u'Phonetic Symbols (US)'],
|
2019-04-06 11:04:58 +08:00
|
|
|
|
['AME_PHON_NO_PREFIX', u'美式音标无前缀', u'Phonetic Symbols (US) no prefix'],
|
2018-07-28 14:10:34 +08:00
|
|
|
|
['IMAGE', u'图片', u'Images'],
|
2018-07-06 20:56:20 +08:00
|
|
|
|
]
|
|
|
|
|
|
|
2023-01-31 11:50:28 +08:00
|
|
|
|
_trans = {item[0]: {'zh-CN': item[1], 'en': item[2]} for item in _arr}
|
2018-07-14 15:24:21 +08:00
|
|
|
|
|
2018-07-06 20:56:20 +08:00
|
|
|
|
|
2023-01-28 00:36:43 +08:00
|
|
|
|
def _(key, lang=current_lang):
|
|
|
|
|
|
"""get local language string"""
|
2023-01-31 11:50:28 +08:00
|
|
|
|
if lang != 'zh-CN' and lang != 'en':
|
2018-07-06 20:56:20 +08:00
|
|
|
|
lang = 'en'
|
2018-07-01 10:55:30 +08:00
|
|
|
|
|
|
|
|
|
|
def disp(s):
|
|
|
|
|
|
return s.lower().capitalize()
|
2019-02-10 11:44:25 +08:00
|
|
|
|
|
2018-07-14 15:24:21 +08:00
|
|
|
|
if key not in _trans or lang not in _trans[key]:
|
2018-07-01 10:55:30 +08:00
|
|
|
|
return disp(key)
|
2018-07-14 15:24:21 +08:00
|
|
|
|
return _trans[key][lang]
|
2018-07-01 10:55:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
2023-01-28 00:36:43 +08:00
|
|
|
|
def _cl(labels, lang=current_lang):
|
|
|
|
|
|
"""get local language string from labels"""
|
2018-07-06 20:56:20 +08:00
|
|
|
|
if isinstance(labels, basestring):
|
|
|
|
|
|
return _(labels)
|
2023-01-31 11:50:28 +08:00
|
|
|
|
if lang != 'zh-CN' and lang != 'en':
|
2018-07-06 20:56:20 +08:00
|
|
|
|
lang = 'en'
|
2023-01-31 11:50:28 +08:00
|
|
|
|
return labels[0] if lang == 'zh-CN' else labels[1]
|
2018-07-06 20:56:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
2018-07-01 10:55:30 +08:00
|
|
|
|
def _sl(key):
|
2018-07-14 15:24:21 +08:00
|
|
|
|
return _trans[key].values()
|