1.1
This commit is contained in:
parent
e1f09671c8
commit
b2bcf9a428
9
LICENSE
Normal file
9
LICENSE
Normal 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
1
package.txt
Normal 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
40
trans.py
Normal 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
26406
zhcdict.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user