forked from Mirrors/RGSX
v2.2.2.5
- fix error messages in history
This commit is contained in:
@@ -13,7 +13,7 @@ except Exception:
|
|||||||
pygame = None # type: ignore
|
pygame = None # type: ignore
|
||||||
|
|
||||||
# Version actuelle de l'application
|
# Version actuelle de l'application
|
||||||
app_version = "2.2.2.4"
|
app_version = "2.2.2.5"
|
||||||
|
|
||||||
|
|
||||||
def get_application_root():
|
def get_application_root():
|
||||||
|
|||||||
@@ -924,38 +924,44 @@ def draw_history_list(screen):
|
|||||||
progress = entry.get("progress", 0)
|
progress = entry.get("progress", 0)
|
||||||
progress = max(0, min(100, progress)) # Clamp progress between 0 and 100
|
progress = max(0, min(100, progress)) # Clamp progress between 0 and 100
|
||||||
|
|
||||||
|
# Precompute provider prefix once
|
||||||
|
provider_prefix = entry.get("provider_prefix") or (entry.get("provider") + ":" if entry.get("provider") else "")
|
||||||
# Compute status text (optimized version without redundant prefix for errors)
|
# Compute status text (optimized version without redundant prefix for errors)
|
||||||
if status in ["Téléchargement", "downloading"]:
|
if status in ["Téléchargement", "downloading"]:
|
||||||
status_text = _("history_status_downloading").format(progress)
|
status_text = _("history_status_downloading").format(progress)
|
||||||
provider_prefix = entry.get("provider_prefix") or (entry.get("provider") + ":" if entry.get("provider") else "")
|
# Coerce to string and prefix provider when relevant
|
||||||
|
status_text = str(status_text or "")
|
||||||
if provider_prefix and not status_text.startswith(provider_prefix):
|
if provider_prefix and not status_text.startswith(provider_prefix):
|
||||||
status_text = f"{provider_prefix} {status_text}"
|
status_text = f"{provider_prefix} {status_text}"
|
||||||
elif status == "Extracting":
|
elif status == "Extracting":
|
||||||
status_text = _("history_status_extracting").format(progress)
|
status_text = _("history_status_extracting").format(progress)
|
||||||
provider_prefix = entry.get("provider_prefix") or (entry.get("provider") + ":" if entry.get("provider") else "")
|
status_text = str(status_text or "")
|
||||||
if provider_prefix and not status_text.startswith(provider_prefix):
|
if provider_prefix and not status_text.startswith(provider_prefix):
|
||||||
status_text = f"{provider_prefix} {status_text}"
|
status_text = f"{provider_prefix} {status_text}"
|
||||||
elif status == "Download_OK":
|
elif status == "Download_OK":
|
||||||
# Completed: no provider prefix (per requirement)
|
# Completed: no provider prefix (per requirement)
|
||||||
status_text = _("history_status_completed")
|
status_text = _("history_status_completed")
|
||||||
|
status_text = str(status_text or "")
|
||||||
elif status == "Erreur":
|
elif status == "Erreur":
|
||||||
# Prefer friendly mapped message now stored in 'message'
|
# Prefer friendly mapped message now stored in 'message'
|
||||||
status_text = entry.get('message')
|
status_text = entry.get('message')
|
||||||
if not status_text:
|
if not status_text:
|
||||||
# Some legacy entries might have only raw in result[1] or auxiliary field
|
# Some legacy entries might have only raw in result[1] or auxiliary field
|
||||||
status_text = entry.get('raw_error_realdebrid') or entry.get('error') or 'Échec'
|
status_text = entry.get('raw_error_realdebrid') or entry.get('error') or 'Échec'
|
||||||
|
# Coerce to string early for safe operations
|
||||||
|
status_text = str(status_text or "")
|
||||||
# Strip redundant prefixes if any
|
# Strip redundant prefixes if any
|
||||||
for prefix in ["Erreur :", "Erreur:", "Error:", "Error :"]:
|
for prefix in ["Erreur :", "Erreur:", "Error:", "Error :"]:
|
||||||
if status_text.startswith(prefix):
|
if status_text.startswith(prefix):
|
||||||
status_text = status_text[len(prefix):].strip()
|
status_text = status_text[len(prefix):].strip()
|
||||||
break
|
break
|
||||||
provider_prefix = entry.get("provider_prefix") or (entry.get("provider") + ":" if entry.get("provider") else "")
|
|
||||||
if provider_prefix and not status_text.startswith(provider_prefix):
|
if provider_prefix and not status_text.startswith(provider_prefix):
|
||||||
status_text = f"{provider_prefix} {status_text}"
|
status_text = f"{provider_prefix} {status_text}"
|
||||||
elif status == "Canceled":
|
elif status == "Canceled":
|
||||||
status_text = _("history_status_canceled")
|
status_text = _("history_status_canceled")
|
||||||
|
status_text = str(status_text or "")
|
||||||
else:
|
else:
|
||||||
status_text = status
|
status_text = str(status or "")
|
||||||
|
|
||||||
# Determine color dedicated to status (independent from selection for better readability)
|
# Determine color dedicated to status (independent from selection for better readability)
|
||||||
if status == "Erreur":
|
if status == "Erreur":
|
||||||
@@ -971,7 +977,7 @@ def draw_history_list(screen):
|
|||||||
platform_text = truncate_text_end(platform, config.small_font, col_platform_width - 10)
|
platform_text = truncate_text_end(platform, config.small_font, col_platform_width - 10)
|
||||||
game_text = truncate_text_end(game_name, config.small_font, col_game_width - 10)
|
game_text = truncate_text_end(game_name, config.small_font, col_game_width - 10)
|
||||||
size_text = truncate_text_end(size_text, config.small_font, col_size_width - 10)
|
size_text = truncate_text_end(size_text, config.small_font, col_size_width - 10)
|
||||||
status_text = truncate_text_middle(status_text, config.small_font, col_status_width - 10, is_filename=False)
|
status_text = truncate_text_middle(str(status_text or ""), config.small_font, col_status_width - 10, is_filename=False)
|
||||||
|
|
||||||
y_pos = rect_y + margin_top_bottom + header_height + idx * line_height + line_height // 2
|
y_pos = rect_y + margin_top_bottom + header_height + idx * line_height + line_height // 2
|
||||||
platform_surface = config.small_font.render(platform_text, True, color)
|
platform_surface = config.small_font.render(platform_text, True, color)
|
||||||
|
|||||||
@@ -68,19 +68,29 @@ def load_language(lang_code=None):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_text(key, default=None):
|
def get_text(key, default=None):
|
||||||
"""Récupère la traduction correspondant à la clé."""
|
"""Récupère la traduction correspondant à la clé en garantissant une chaîne.
|
||||||
if not translations:
|
|
||||||
load_language()
|
- Ne retourne jamais None: fallback vers default (si fourni) sinon la clé.
|
||||||
|
- Si la valeur traduite n'est pas une chaîne (liste/dict/etc.), fallback similaire.
|
||||||
if key in translations:
|
"""
|
||||||
return translations[key]
|
try:
|
||||||
|
if not translations:
|
||||||
# Si la clé n'existe pas, retourner la valeur par défaut ou la clé elle-même
|
load_language()
|
||||||
if default is not None:
|
# Valeur brute potentielle
|
||||||
return default
|
val = translations.get(key) if isinstance(translations, dict) else None
|
||||||
|
if isinstance(val, str) and val:
|
||||||
logger.warning(f"Clé de traduction '{key}' non trouvée dans la langue {current_language}")
|
return val
|
||||||
return key
|
# Fallback: utiliser default si fourni
|
||||||
|
if isinstance(default, str) and default:
|
||||||
|
return default
|
||||||
|
# Dernier recours: retourner la clé elle-même (stringifiée)
|
||||||
|
return str(key)
|
||||||
|
except Exception as e:
|
||||||
|
try:
|
||||||
|
logger.warning(f"get_text fallback for key={key}: {e}")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return str(default) if default is not None else str(key)
|
||||||
|
|
||||||
def get_available_languages():
|
def get_available_languages():
|
||||||
"""Récupère la liste des langues disponibles."""
|
"""Récupère la liste des langues disponibles."""
|
||||||
|
|||||||
Reference in New Issue
Block a user