import json from typing import Any from typing import Dict from typing import IO from typing import List from typing import Optional from typing import Tuple from typing import Union def load_ui_language(file_path: Optional[str] = "ui_lang_support.json") -> Dict[str, Any]: """ Charge les traductions de l'interface utilisateur à partir d'un fichier JSON. Args: file_path (Optional[str]): Chemin vers le fichier JSON contenant les traductions. Returns: Dict[str, Any]: Un dictionnaire contenant les traductions de l'interface utilisateur. """ try: with open(file_path, 'r', encoding='utf-8') as file: return json.load(file) except FileNotFoundError: print(f"File Not Found: {file_path}") return None except json.JSONDecodeError: print(f"JSON decoding error : {file_path}") return None except IOError as e: print(f"I/O Error : {e}") return None # usage e.g.: read a plaintext prompt file def read_file(file_name: str) -> str: """ Lit et retourne le contenu des fichiers texte. Args: file_name (str): Le nom du fichier à lire. Returns: str: Le contenu du fichier ou un message d'erreur. """ try: with open(file_name, 'r', encoding='utf-8') as file: content = file.read() return content except FileNotFoundError: return f"File Not Found : {file_name}" except IOError as e: return f"I/O Error : {str(e)}"