anki-word-query/src/fastwq/lang.py

106 lines
4.4 KiB
Python
Raw Normal View History

2018-07-28 14:10:34 +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/>.
from anki.lang import currentLang
__all__ = ['_', '_cl', '_sl']
#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'],
['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'],
['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>'],
2018-07-28 14:10:34 +08:00
['RADIOS_DESC', u'<b>单选框选中为待查询单词字段</b>', u'<b> Select the field to be queried with single selection.</b>'],
['NO_QUERY_WORD', u'查询字段无单词', u'The query field is empty'],
['CSS_NOT_FOUND', u'没有找到CSS文件请手动选择', u'No CSS file found, please select one manually.'],
['ABOUT', u'关于', u'About'],
2018-07-08 00:54:05 +08:00
['REPOSITORY', u'项目地址', u'Project Repo'],
['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.'],
['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:'],
['UPDATE', u'更新', u'Update'],
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:10:34 +08:00
['SKIP_VALUED', u'跳过有值项', u'Skip non-empty Fields'],
['SKIPED', u'略过', 'Skipped'],
['SETTINGS', u'参数', u'Settings'],
2018-07-28 14:10:34 +08:00
['THREAD_NUMBER', u'线程数', u'Number of Threads'],
['INITLIZING_DICT', u'初始化词典...', u'Initlizing Dictionary...'],
2018-07-28 14:10:34 +08:00
['PLS_SET_DICTIONARY_FIELDS', u'请设置字典和字段', u'Please set the dictionary and fields.'],
['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'],
['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)'],
['AME_PHON', u'美式音标', u'Phonetic Symbols (US)'],
['IMAGE', u'图片', u'Images'],
]
2018-07-14 15:24:21 +08:00
_trans = {item[0]: {'zh_CN': item[1], 'en': item[2]} for item in _arr}
2018-07-01 10:55:30 +08:00
def _(key, lang=currentLang):
2018-07-14 15:24:21 +08:00
'''get local language string'''
if lang != 'zh_CN' and lang != 'en':
lang = 'en'
2018-07-01 10:55:30 +08:00
def disp(s):
return s.lower().capitalize()
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
def _cl(labels, lang=currentLang):
2018-07-14 15:24:21 +08:00
'''get local language string from labels'''
if isinstance(labels, basestring):
return _(labels)
if lang != 'zh_CN' and lang != 'en':
lang = 'en'
return labels[0] if lang == 'zh_CN' else labels[1]
2018-07-01 10:55:30 +08:00
def _sl(key):
2018-07-14 15:24:21 +08:00
return _trans[key].values()