From a8c1d409f9439c7f73eccf7636746b7bd5c79281 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Wed, 19 Jan 2022 12:54:45 -0500 Subject: [PATCH] adding localization support in birdnet-pi-config --- model/labels_lang.txt | 33 +++++++++++++++++++++++++++++++++ scripts/birdnet-pi-config | 24 +++++++++++++++++++++--- 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 model/labels_lang.txt diff --git a/model/labels_lang.txt b/model/labels_lang.txt new file mode 100644 index 0000000..199bef3 --- /dev/null +++ b/model/labels_lang.txt @@ -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 + + diff --git a/scripts/birdnet-pi-config b/scripts/birdnet-pi-config index d6ede12..1007185 100755 --- a/scripts/birdnet-pi-config +++ b/scripts/birdnet-pi-config @@ -4,7 +4,7 @@ # # See LICENSE file for copyright and license details # Copyright (c) 2012 Alex Bradbury -#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