-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlangue.sh
50 lines (42 loc) · 1.28 KB
/
langue.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Function to display language selection menu
select_language() {
clear
echo "Select your language:"
options=("French" "English")
selected=0
while true; do
for i in "${!options[@]}"; do
if [ $i -eq $selected ]; then
echo -e "-> ${options[i]}"
else
echo " ${options[i]}"
fi
done
read -rsn1 key
case $key in
$'\x1B') # Handle arrow keys
read -rsn2 -t 0.1 key
if [ "$key" == "[A" ] && [ $selected -gt 0 ]; then
((selected--))
elif [ "$key" == "[B" ] && [ $selected -lt $((${#options[@]}-1)) ]; then
((selected++))
fi ;;
$'\n') # Enter key to select
echo "Selected language: ${options[selected]}"
case $selected in
0) echo "French selected."
# Script en français
# ... (Ton script français ici)
;;
1) echo "English selected."
# Script en anglais
# ... (Ton script anglais ici)
;;
esac
return $selected ;;
esac
done
}
# Call the function to select language
select_language