Skip to content

A live bird collage card for your Home Assistant dashboard.

adding web GUI labels.txt language selection support

mcguirepr897c5a80b1fe9f
diff --git a/scripts/config.php b/scripts/config.php
index 08edfa89..63138977 100644
--- a/scripts/config.php
+++ b/scripts/config.php
@@ -87,12 +87,10 @@ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
} ?>
- <h3>Required</h3>
<label for="latitude">Latitude: </label>
- <input name="latitude" type="text" value="<?php print($config['LATITUDE']);?>" /><br>
+ <input name="latitude" type="text" value="<?php print($config['LATITUDE']);?>" required/><br>
<label for="longitude">Longitude: </label>
- <input name="longitude" type="text" value="<?php print($config['LONGITUDE']);?>" />
- <h3>Optional</h3>
+ <input name="longitude" type="text" value="<?php print($config['LONGITUDE']);?>" required/><br>
<label for="birdweather_id">BirdWeather ID: </label>
<input name="birdweather_id" type="text" value="<?php print($config['BIRDWEATHER_ID']);?>" /><br>
<label for="pushed_app_key">Pushed App Key: </label>
@@ -100,6 +98,40 @@ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
<label for="pushed_app_secret">Pushed App Secret: </label>
<input name="pushed_app_secret" type="text" value="<?php print($config['PUSHED_APP_SECRET']);?>" /><br>
<br>
+ <label for"language">Database Language: </label>
+ <select name="language">
+ <option value="none">Select your language</option>
+ <option value="labels_af.txt">Afrikaans</option>
+ <option value="labels_ca.txt">Catalan</option>
+ <option value="labels_cs.txt">Czech</option>
+ <option value="labels_zh.txt">Chinese</option>
+ <option value="labels_hr.txt">Croatian</option>
+ <option value="labels_da.txt">Danish</option>
+ <option value="labels_nl.txt">Dutch</option>
+ <option value="labels_en.txt">English</option>
+ <option value="labels_et.txt">Estonian</option>
+ <option value="labels_fi.txt">Finnish</option>
+ <option value="labels_fr.txt">French</option>
+ <option value="labels_de.txt">German</option>
+ <option value="labels_hu.txt">Hungarian</option>
+ <option value="labels_is.txt">Icelandic</option>
+ <option value="labels_id.txt">Indonesia</option>
+ <option value="labels_it.txt">Italian</option>
+ <option value="labels_ja.txt">Japanese</option>
+ <option value="labels_lv.txt">Latvian</option>
+ <option value="labels_lt.txt">Lithuania</option>
+ <option value="labels_no.txt">Norwegian</option>
+ <option value="labels_pl.txt">Polish</option>
+ <option value="labels_pt.txt">Portugues</option>
+ <option value="labels_ru.txt">Russian</option>
+ <option value="labels_sk.txt">Slovak</option>
+ <option value="labels_sl.txt">Slovenian</option>
+ <option value="labels_es.txt">Spanish</option>
+ <option value="labels_sv.txt">Swedish</option>
+ <option value="labels_th.txt">Thai</option>
+ <option value="labels_uk.txt">Ukrainian</option>
+ </select>
+ <br><br>
<input type="submit" value="<?php
@session_start();
@@ -109,7 +141,7 @@ if(isset($_SESSION['success'])){
} else {
echo "Update Settings";
}
-?>">
+?>">
<br>
<br>
<button type="text"><a href="advanced.php">Advanced Settings</a></button>
diff --git a/scripts/write_config.php b/scripts/write_config.php
index 4da9a4bc..6c993456 100644
--- a/scripts/write_config.php
+++ b/scripts/write_config.php
@@ -29,5 +29,18 @@ if(true){
$_SESSION['success'] = 1;
header("Location:config.php");
}
+
+$language = $_POST["language"];
+if ($language != "none"){
+ $command = "sudo -upi set -x; sudo -upi mv /home/pi/BirdNET-Pi/model/labels.txt /home/pi/BirdNET-Pi/model/labels.txt.old && sudo -upi unzip /home/pi/BirdNET-Pi/model/labels_l18n.zip $language -d /home/pi/BirdNET-Pi/model && sudo -upi mv /home/pi/BirdNET-Pi/model/$language /home/pi/BirdNET-Pi/model/labels.txt";
+ $command_output = `$command`;
+ echo $command_output;
+ @session_start();
+
+ if(true){
+ $_SESSION['success'] = 1;
+ header("Location:config.php");
+ }
+}
?>