6
6
import winreg
7
7
import locale
8
8
9
+
9
10
def load_language (lang_code : str = None ) -> Dict :
10
11
"""
11
12
加载语言文件,如果指定语言不存在则回退到英语。
@@ -16,34 +17,105 @@ def load_language(lang_code: str = None) -> Dict:
16
17
if locale .getdefaultlocale ()[0 ]
17
18
else "en"
18
19
)
19
-
20
- lang_folder = "lang"
21
- lang_file = os .path .join (lang_folder , f"{ lang_code } .json" )
22
- fallback_file = os .path .join (lang_folder , "en.json" )
23
-
24
- # 确保 lang 文件夹存在
25
- if not os .path .exists (lang_folder ):
26
- os .makedirs (lang_folder )
27
-
28
- # 尝试加载指定语言文件
29
- if os .path .exists (lang_file ):
30
- with open (lang_file , "r" , encoding = "utf-8" ) as f :
31
- return json .load (f )
20
+ en_lang = {
21
+ "app_title" : "INVAXION Patch Tool - GamerNoTitle" ,
22
+ "copyright" : "Copyright © 2025 GamerNoTitle. All rights reserved.\n INVAXION 音灵 is a registed trademark of Aquatrax.\n The developer of this tool is not affiliated with Aquatrax." ,
23
+ "github" : "Github" ,
24
+ "select_directory" : "Select Directory" ,
25
+ "patch_all" : "Patch All" ,
26
+ "patch_char" : "Patch Character" ,
27
+ "patch_song" : "Patch Song" ,
28
+ "patch_theme" : "Patch Theme" ,
29
+ "no_directory_selected" : "No Directory Selected" ,
30
+ "read_success_title" : "Successfully Read" ,
31
+ "read_success_content" : "Successfully found Song, Character, and theme data" ,
32
+ "error_title" : "Error" ,
33
+ "error_invaxion_exe" : "INVAXION.exe not found. Please ensure you have selected the game directory or that the game is installed correctly." ,
34
+ "error_invaxion_data" : "INVAXION_DATA folder not found. Please ensure you have selected the game directory or that the game is installed correctly." ,
35
+ "error_streaming_assets" : "StreamingAssets folder not found. Please ensure you have selected the game directory or that the game is installed correctly." ,
36
+ "warning_title" : "Warning" ,
37
+ "warning_empty_data" : "Data for {key_name} is empty: {data_str}" ,
38
+ "warning_empty_bytes" : "Encoded data is empty, cannot write to {key_name}" ,
39
+ "warning_partial_failure" : "Partial Patch failed, please check error messages!" ,
40
+ "steam" : "Developer's Steam" ,
41
+ "success_title" : "Completed" ,
42
+ "success_patch_all" : "Successfully Patched Character, Song, and Starship" ,
43
+ "success_patch_char" : "Successfully Patched Character" ,
44
+ "success_patch_song" : "Successfully Patched Song" ,
45
+ "success_patch_theme" : "Successfully Patched Starship" ,
46
+ "registry_error" : "Registry write error ({key_name}): {error_msg}" ,
47
+ }
48
+ zh_cn_lang = {
49
+ "app_title" : "INVAXION 音灵全解锁补丁 - GamerNoTitle" ,
50
+ "copyright" : "Copyright © 2025 GamerNoTitle, 保留所有权利。\n NVAXION 音灵是 Aquatrax 的注册商标。\n 本工具的开发者与 Aquatrax 无关。" ,
51
+ "github" : "Github" ,
52
+ "select_directory" : "选择游戏目录" ,
53
+ "patch_all" : "我全都要!" ,
54
+ "patch_char" : "应用补丁到角色" ,
55
+ "patch_song" : "应用补丁到铺面" ,
56
+ "patch_theme" : "应用补丁到星舰" ,
57
+ "no_directory_selected" : "未选择目录" ,
58
+ "read_success_title" : "读取成功" ,
59
+ "read_success_content" : "成功找到铺面、角色和星舰数据" ,
60
+ "error_title" : "错误" ,
61
+ "error_invaxion_exe" : "未找到 INVAXION.exe,请确认你选择的是游戏所在的目录或者游戏安装完整。" ,
62
+ "error_invaxion_data" : "未找到 INVAXION_DATA 文件夹,请确认你选择的是游戏所在的目录或者游戏安装完整。" ,
63
+ "error_streaming_assets" : "未找到 StreamingAssets 文件夹,请确认你选择的是游戏所在的目录或者游戏安装完整。" ,
64
+ "warning_title" : "警告" ,
65
+ "warning_empty_data" : "写入 {key_name} 的数据为空: {data_str}" ,
66
+ "warning_empty_bytes" : "编码后的数据为空,无法写入 {key_name}" ,
67
+ "warning_partial_failure" : "部分数据应用补丁失败,请检查错误信息!" ,
68
+ "steam" : "我的 Steam" ,
69
+ "success_title" : "完成" ,
70
+ "success_patch_all" : "成功应用补丁到角色、铺面和星舰" ,
71
+ "success_patch_char" : "成功应用补丁到角色" ,
72
+ "success_patch_song" : "成功应用补丁到铺面" ,
73
+ "success_patch_theme" : "成功应用补丁到星舰" ,
74
+ "registry_error" : "注册表写入错误 ({key_name}): {error_msg}" ,
75
+ }
76
+ zh_tw_lang = {
77
+ "app_title" : "INVAXION 音靈全解鎖補丁 - GamerNoTitle" ,
78
+ "copyright" : "Copyright © 2025 GamerNoTitle,保留所有權利。\n INVAXION 音靈是 Aquatrax 的註冊商標。\n 本工具的開發者與 Aquatrax 無關。" ,
79
+ "github" : "Github" ,
80
+ "select_directory" : "選擇遊戲目錄" ,
81
+ "patch_all" : "我全都要!" ,
82
+ "patch_char" : "應用補丁到角色" ,
83
+ "patch_song" : "應用補丁到譜面" ,
84
+ "patch_theme" : "應用補丁到星艦" ,
85
+ "no_directory_selected" : "未選擇目錄" ,
86
+ "read_success_title" : "讀取成功" ,
87
+ "read_success_content" : "成功找到譜面、角色和星艦資料" ,
88
+ "error_title" : "錯誤" ,
89
+ "error_invaxion_exe" : "未找到 INVAXION.exe,請確認您選擇的是遊戲所在的目錄或遊戲安裝完整。" ,
90
+ "error_invaxion_data" : "未找到 INVAXION_DATA 資料夾,請確認您選擇的是遊戲所在的目錄或遊戲安裝完整。" ,
91
+ "error_streaming_assets" : "未找到 StreamingAssets 資料夾,請確認您選擇的是遊戲所在的目錄或遊戲安裝完整。" ,
92
+ "warning_title" : "警告" ,
93
+ "warning_empty_data" : "寫入 {key_name} 的資料為空: {data_str}" ,
94
+ "warning_empty_bytes" : "編碼後的資料為空,無法寫入 {key_name}" ,
95
+ "warning_partial_failure" : "部分資料應用補丁失敗,請檢查錯誤訊息!" ,
96
+ "steam" : "我的 Steam" ,
97
+ "success_title" : "完成" ,
98
+ "success_patch_all" : "成功應用補丁到角色、譜面和星艦" ,
99
+ "success_patch_char" : "成功應用補丁到角色" ,
100
+ "success_patch_song" : "成功應用補丁到譜面" ,
101
+ "success_patch_theme" : "成功應用補丁到星艦" ,
102
+ "registry_error" : "登錄檔寫入錯誤 ({key_name}): {error_msg}" ,
103
+ }
104
+
105
+ if lang_code .startswith ("zh-CN" ):
106
+ return zh_cn_lang
107
+ elif lang_code .startswith ("zh-TW" ):
108
+ return zh_tw_lang
32
109
else :
33
- # 如果不存在,尝试加载英语文件
34
- if os .path .exists (fallback_file ):
35
- with open (fallback_file , "r" , encoding = "utf-8" ) as f :
36
- return json .load (f )
37
- else :
38
- # 如果英语文件也不存在,返回空字典(或硬编码默认值,这里省略)
39
- return {}
110
+ return en_lang
111
+
40
112
41
113
def main (page : ft .Page ):
42
114
# 动态设置窗口大小
43
115
page .window .width = 600 # 设置窗口宽度
44
116
page .window .height = 400 # 设置窗口高度
45
117
page .window .resizable = False # 允许用户调整窗口大小
46
-
118
+
47
119
# 加载语言文件
48
120
lang = load_language ()
49
121
@@ -79,18 +151,20 @@ def main(page: ft.Page):
79
151
on_click = lambda e : patch_single ("theme" ),
80
152
disabled = True ,
81
153
)
82
-
154
+
83
155
github_button = ft .ElevatedButton (
84
156
lang .get ("github" , "GitHub" ),
85
- on_click = lambda e : page .launch_url ("https://github.com/GamerNoTitle/INVAXION-Unlocker" )
157
+ on_click = lambda e : page .launch_url (
158
+ "https://github.com/GamerNoTitle/INVAXION-Unlocker"
159
+ ),
86
160
)
87
161
steam_button = ft .ElevatedButton (
88
162
lang .get ("steam" , "Developer's Steam" ),
89
- on_click = lambda e : page .launch_url ("https://steamcommunity.com/id/bili33" )
163
+ on_click = lambda e : page .launch_url ("https://steamcommunity.com/id/bili33" ),
90
164
)
91
165
sponsor_button = ft .ElevatedButton (
92
166
lang .get ("sponsor" , "Sponsor" ),
93
- on_click = lambda e : page .launch_url ("https://bili33.top/sponsors" )
167
+ on_click = lambda e : page .launch_url ("https://bili33.top/sponsors" ),
94
168
)
95
169
96
170
# 全局变量存储数据
@@ -364,7 +438,10 @@ def patch_all():
364
438
),
365
439
ft .Divider (),
366
440
ft .Text (
367
- lang .get ("copyright" , "Copyright © 2025 GamerNoTitle. All rights reserved.\n INVAXION 音灵 is a registed trademark of Aquatrax.\n The developer of this tool is not affiliated with Aquatrax." ),
441
+ lang .get (
442
+ "copyright" ,
443
+ "Copyright © 2025 GamerNoTitle. All rights reserved.\n INVAXION 音灵 is a registed trademark of Aquatrax.\n The developer of this tool is not affiliated with Aquatrax." ,
444
+ ),
368
445
size = 14 ,
369
446
text_align = ft .TextAlign .CENTER ,
370
447
),
@@ -375,5 +452,6 @@ def patch_all():
375
452
)
376
453
)
377
454
455
+
378
456
if __name__ == "__main__" :
379
- ft .app (target = main )
457
+ ft .app (target = main )
0 commit comments