This commit is contained in:
Fiber 2024-03-29 16:33:35 +08:00
parent e1f09671c8
commit b2bcf9a428
4 changed files with 26456 additions and 0 deletions

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2023 leaf
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
package.txt Normal file
View File

@ -0,0 +1 @@
pyinstaller trans.py --add-data="C:\\Users\\leaf\\Code\\python\\trans_tts\\zhcdict.json;.\zhconv" -F --upx-dir="C:\\Users\\leaf\\Apps\\upx"

40
trans.py Normal file
View File

@ -0,0 +1,40 @@
from sys import argv
from os import makedirs
from os.path import exists
from chardet import detect
from tkinter import filedialog, Tk
from zhconv import convert
print("繁体字转简体字",flush=True)
file_list = argv[1:]
if file_list == []:
root = Tk()
root.withdraw()
file_list = filedialog.askopenfilenames()
for file_name in file_list:
name =file_name.split("/")[-1]
print("转换:"+name+"...", end="", flush=True)
# 判断文件类型
with open(file_name, 'rb') as f:
file_type = detect(f.read())['encoding']
# 读取文件
with open(file_name,"r", encoding=file_type) as f:
data = f.read()
#修改编码
data = convert(data, "zh-hans")
#写入文件
dir_name = "Translated"
if not exists(dir_name):
makedirs(dir_name)
with open(dir_name+"/"+name, "w", encoding=file_type) as f:
f.write(data)
print("Done")
print("请按回车键或直接关闭窗口")
input()

26406
zhcdict.json Normal file

File diff suppressed because one or more lines are too long