@@ -325,13 +325,13 @@ def should_compile_file(
325325 def apply_i18n (self , gui , tr : dict ) -> None :
326326 """Apply internationalization translations to the engine UI."""
327327 try :
328- from Core .engines_loader .registry import resolve_language_code
328+ from Core .engines_loader .registry import resolve_language_code , load_engine_language_file
329329
330330 # Resolve language code
331331 code = resolve_language_code (gui , tr )
332332
333333 # Load engine-local translations
334- lang_data = self . _load_language_file ( code )
334+ lang_data = load_engine_language_file ( __package__ , code )
335335
336336 # Apply translations to UI elements if they exist
337337 if hasattr (self , "_opt_onefile" ) and "onefile_checkbox" in lang_data :
@@ -362,54 +362,6 @@ def apply_i18n(self, gui, tr: dict) -> None:
362362 except Exception :
363363 pass
364364
365- def _load_language_file (self , code : str ) -> dict :
366- """Load language file for the given code."""
367- try :
368- import importlib .resources as ilr
369- import json
370-
371- pkg = __package__
372- lang_data = {}
373-
374- # Try exact code first
375- try :
376- with ilr .as_file (
377- ilr .files (pkg ).joinpath ("languages" , f"{ code } .json" )
378- ) as p :
379- if os .path .isfile (str (p )):
380- with open (str (p ), encoding = "utf-8" ) as f :
381- lang_data = json .load (f ) or {}
382- return lang_data
383- except Exception :
384- pass
385-
386- # Fallback to base language (e.g., "fr" from "fr-CA")
387- if "-" in code :
388- base = code .split ("-" , 1 )[0 ]
389- try :
390- with ilr .as_file (
391- ilr .files (pkg ).joinpath ("languages" , f"{ base } .json" )
392- ) as p :
393- if os .path .isfile (str (p )):
394- with open (str (p ), encoding = "utf-8" ) as f :
395- lang_data = json .load (f ) or {}
396- return lang_data
397- except Exception :
398- pass
399-
400- # Final fallback to English
401- try :
402- with ilr .as_file (ilr .files (pkg ).joinpath ("languages" , "en.json" )) as p :
403- if os .path .isfile (str (p )):
404- with open (str (p ), encoding = "utf-8" ) as f :
405- lang_data = json .load (f ) or {}
406- except Exception :
407- pass
408-
409- return lang_data
410- except Exception :
411- return {}
412-
413365 def add_data (self ) -> None :
414366 """Add data files or directories to be included with PyInstaller."""
415367 choix , ok = QInputDialog .getItem (
0 commit comments