adding localization support in birdnet-pi-config

This commit is contained in:
mcguirepr89
2022-01-19 12:54:45 -05:00
parent eb799f6b82
commit a8c1d409f9
2 changed files with 54 additions and 3 deletions
+33
View File
@@ -0,0 +1,33 @@
Afrikaans,labels_af.txt
Catalan,labels_ca.txt
Czech,labels_cs.txt
Chinese,labels_zh.txt
Chinese_(Traditional),not_available
Croatian,labels_hr.txt
Danish,labels_da.txt
Dutch,labels_nl.txt
English,labels_en.txt
Estonian,labels_et.txt
Finnish,labels_fi.txt
French,labels_fr.txt
German,labels_de.txt
Hungarian,labels_hu.txt
Icelandic,labels_is.txt
Indonesia,labels_id.txt
Italian,labels_it.txt
Japanese,labels_ja.txt
Latvian,labels_lv.txt
Lithuania,labels_lt.txt
Northern_Sami,not_available
Norwegian,labels_no.txt
Polish,labels_pl.txt
Portugues,labels_pt.txt
Russian,labels_ru.txt
Slovak,labels_sk.txt
Slovenian,labels_sl.txt
Spanish,labels_es.txt
Swedish,labels_sv.txt
Thai,labels_th.txt
Ukrainian,labels_uk.txt
+21 -3
View File
@@ -4,7 +4,7 @@
#
# See LICENSE file for copyright and license details
# Copyright (c) 2012 Alex Bradbury <asb@asbradbury.org>
#set -x
set -x
birdnetpi_dir=/home/pi/BirdNET-Pi
birders_config=${birdnetpi_dir}/Birders_Guide_Installer_Configuration.txt
branch=main
@@ -219,6 +219,22 @@ do_wifi_country() {
IFS=$oIFS
}
get_labels_lang() {
oIFS="$IFS"
#value=$(unzip -l ${birdnetpi_dir}/model/labels_l18n.zip | awk '{print $4}' | tail -n +4 | grep -ve '^$' | tr '\n' '/')
value=$(cat ${birdnetpi_dir}/model/labels_lang.txt | tr ',' ' ' | tr '\n' ' ')
IFS=" "
get_lang=$(whiptail --menu "Select the file that corresponds to your language" 20 60 10 ${value} 3>&1 1>&2 2>&3)
labels_lang=$(awk -F, "/$get_lang/{print \$2}" ${birdnetpi_dir}/model/labels_lang.txt)
if [ $? -eq 0 ];then
whiptail --msgbox "Your installation will now use $labels_lang" 20 60 1
mv ${birdnetpi_dir}/model/labels.txt ${birdnetpi_dir}/model/labels.txt.old
unzip ${birdnetpi_dir}/model/labels_l18n.zip ${labels_lang} -d ${birdnetpi_dir}/model
mv ${birdnetpi_dir}/model/${labels_lang} ${birdnetpi_dir}/model/labels.txt
fi
IFS=$oIFS
}
get_ssh() {
if service ssh status | grep -q inactive; then
echo 1
@@ -925,7 +941,8 @@ do_internationalisation_menu() {
MENU=1
while [ $MENU -eq 1 ];do
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Localisation Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Locale" "Configure language and regional settings" \
"System Locale" "Configure the system language and regional settings" \
"labels.txt" "Set the language to use for species detection" \
"Time Zone" "Set the Time Zone" \
3>&1 1>&2 2>&3)
RET=$?
@@ -934,7 +951,8 @@ do_internationalisation_menu() {
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
Locale*) do_change_locale;;
System*) do_change_locale;;
label*) get_labels_lang;;
Time*) do_change_timezone;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1