mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2025-09-05 11:56:23 +00:00
慢慢更新。
This commit is contained in:
@ -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 = ''
|
||||
|
@ -1,4 +1,12 @@
|
||||
# 音·创 本地化语言文件
|
||||
# 使用 空格 把键与对应文本隔开
|
||||
# 使用 井字符 在每一行的开头编写注释
|
||||
# 注意!井字符请开头放,切勿含有空格
|
||||
# 或者在正文结尾放!
|
||||
LANGKEY zh-CN
|
||||
LANGCHINESENAME 简体中文 中国大陆
|
||||
LANGENGLIFHNAME Simplified Chinese, Chinese Mainland
|
||||
LANGLOCALNAME 简体中文 中国大陆
|
||||
MSCT 音·创
|
||||
F音创 音·创 Musicreater
|
||||
关于 音·创 - 关于
|
||||
|
Reference in New Issue
Block a user