#!/bin/bash # Translate Shell CLI # Conçu avec l'aide de ChatGPT # Liste des langues principales main_langs=("fr:en" "en:fr" "fr:pt" "pt:fr" "en:pt" "pt:en") # Fonction pour afficher le menu principal function main_menu() { echo "=== MENU PRINCIPAL ===" echo "1. Français - Anglais" echo "2. Anglais - Français" echo "3. Français - Portugais" echo "4. Portugais - Français" echo "5. Anglais - Portugais" echo "6. Portugais - Anglais" echo "7. Autre langue" echo "8. Quitter" } # Fonction pour afficher la liste de toutes les langues disponibles function list_all_langs() { echo "=== LISTE DES LANGUES ===" trans -list | awk '{print NR". "$0}' } # Fonction pour traduire le texte function translate_text() { read -p "Texte à traduire: " text if [[ "$lang_choice" == "7" ]]; then read -p "Langue source-cible (ex: en:fr): " lang_choice trans "$lang_choice" "$text" else # echo DEBUG trans "${main_langs[$lang_choice-1]}" "$text" trans "${main_langs[$lang_choice-1]}" "$text" fi } # Boucle principale while true; do clear main_menu read -n 1 -p "Choix: " lang_choice;echo case "$lang_choice" in 1|2|3|4|5|6) translate_text read -p "Appuyez sur une touche pour continuer..." ;; 7) list_all_langs read -p "Langue source-cible (ex: en-fr): " lang_choice translate_text read -p "Appuyez sur une touche pour continuer..." ;; 8) exit 0 ;; *) echo "Choix invalide." read -p "Appuyez sur une touche pour continuer..." ;; esac done