慢慢更新。

This commit is contained in:
2022-03-24 01:01:45 +08:00
parent 245e2fa1ec
commit 26ec42a71d
14 changed files with 73 additions and 97 deletions

View File

@ -58,15 +58,21 @@ except:
pass
from msctLib.log import log
def __loadLanguage(languageFilename: str):
with open(languageFilename, 'r', encoding='utf-8') as languageFile:
_text = {}
for line in languageFile:
if line.startswith('#'):
continue
line = line.split(' ', 1)
_text[line[0]] = line[1].replace('\n', '')
langkeys = _text.keys()
with open(languageFilename.replace(languageFilename[-10:-5], 'zh-CN'), 'r', encoding='utf-8') as defaultLangFile:
for line in defaultLangFile:
if line.startswith('#'):
continue
line = line.split(' ', 1)
if not line[0] in langkeys:
_text[line[0]] = line[1].replace('\n', '')
@ -90,7 +96,6 @@ def wordTranslate(singleWord: str, debug: bool = False):
requests.post('https://fanyi.baidu.com/sug', data={'kw': f'{singleWord}'}).json()['data'][0]['v'].split(
'; ')[0]
except:
from msctLib.log import log
log(f"无法翻译文本{singleWord}", level='WARRING', isPrinted=debug)
return None
@ -102,7 +107,8 @@ def _(text: str, debug: bool = False):
if debug:
raise KeyError(f'无法找到翻译文本{text}')
else:
return None
log(f'无法找到本地化文本{text}','ERROR')
return ''
if __name__ == '__main__':
@ -148,8 +154,6 @@ if __name__ == '__main__':
root.geometry('600x500')
root.bind_all(func=_autoSave)
root.bind("<Motion>", _autoSave)
nowText = ''

View File

@ -1,4 +1,12 @@
# 音·创 本地化语言文件
# 使用 空格 把键与对应文本隔开
# 使用 井字符 在每一行的开头编写注释
# 注意!井字符请开头放,切勿含有空格
# 或者在正文结尾放!
LANGKEY zh-CN
LANGCHINESENAME 简体中文 中国大陆
LANGENGLIFHNAME Simplified Chinese, Chinese Mainland
LANGLOCALNAME 简体中文 中国大陆
MSCT 音·创
F音创 音·创 Musicreater
关于 音·创 - 关于