@@ -132,7 +132,7 @@ class Dictionary(TkinterDnD.Tk):
132132 self .local_var = tk .StringVar (value = self .current_local )
133133 self .selected_g2p = config .get ('Settings' , 'g2p' , fallback = "Arpabet-Plus G2p" )
134134 self .g2p_var = tk .StringVar (value = self .selected_g2p )
135- self .current_version = "v1.7.0 "
135+ self .current_version = "v1.7.5 "
136136
137137 # Set window title
138138 self .base_title = "OpenUTAU Dictionary Editor"
@@ -188,6 +188,7 @@ class Dictionary(TkinterDnD.Tk):
188188 self .icon ()
189189 # Start update check in a non-blocking way
190190 threading .Thread (target = self .bg_updates , daemon = True ).start ()
191+ threading .Thread (target = self .update_localization_files , daemon = True ).start ()
191192 self .load_whats_new_state ()
192193 self .check_and_update_version ()
193194 # Check if "What's New" should be displayed
@@ -4806,6 +4807,49 @@ class Dictionary(TkinterDnD.Tk):
48064807 with open (self .config_file , 'w' ) as configfile :
48074808 config .write (configfile )
48084809 print (f"'What's New' state { state } and version { self .current_version } saved to config file." )
4810+
4811+ def update_localization_files (self ):
4812+ if not self .is_connected ():
4813+ return
4814+
4815+ try :
4816+ api_url = "https://api.github.com/repos/Cadlaxa/OpenUtau-Dictionary-Editor/contents/OU%20Dictionary%20Editor/Templates/Localizations"
4817+ response = requests .get (api_url )
4818+ response .raise_for_status ()
4819+ files = response .json ()
4820+
4821+ updated = False
4822+ local_dir = os .path .join ("Templates" , "Localizations" )
4823+ os .makedirs (local_dir , exist_ok = True )
4824+
4825+ for file_info in files :
4826+ file_name = file_info ['name' ]
4827+ download_url = file_info ['download_url' ]
4828+ remote_sha = file_info ['sha' ]
4829+ local_file_path = os .path .join (local_dir , file_name )
4830+ sha_file_path = local_file_path + ".sha"
4831+
4832+ local_sha = None
4833+ if os .path .exists (local_file_path ) and os .path .exists (sha_file_path ):
4834+ with open (sha_file_path , 'r' , encoding = 'utf-8' ) as f :
4835+ local_sha = f .read ().strip ()
4836+
4837+ if local_sha != remote_sha :
4838+ file_response = requests .get (download_url )
4839+ file_response .raise_for_status ()
4840+ with open (local_file_path , 'wb' ) as local_file :
4841+ local_file .write (file_response .content )
4842+ with open (sha_file_path , 'w' , encoding = 'utf-8' ) as sha_file :
4843+ sha_file .write (remote_sha )
4844+ updated = True
4845+
4846+ if updated :
4847+ messagebox .showinfo ("Localization Updated" , self .localization .get (
4848+ 'localization_updated' , 'Localization files have been updated successfully.' ))
4849+
4850+ except requests .RequestException as e :
4851+ messagebox .showerror ("Localization Error" , self .localization .get (
4852+ 'localization_err' , 'Failed to update localization files: ' ) + str (e ))
48094853
48104854 def check_and_update_version (self ):
48114855 # Check if the app version is updated and update the config
0 commit comments