Work on lang #332

This commit is contained in:
Jokob-sk
2023-08-10 07:13:04 +10:00
parent a0d02b2aa5
commit 320660945c
6 changed files with 25 additions and 8 deletions

View File

@@ -193,6 +193,11 @@ function getString (key) {
}
result = getCache(`pia_lang_${key}_${lang_code}`, true);
if(isEmpty(result))
{
result = getCache(`pia_lang_${key}_en_us`, true);
}
return result;
}
@@ -476,6 +481,12 @@ function navigateToDeviceWithIp (ip) {
});
}
// -----------------------------------------------------------------------------
function isEmpty(value)
{
return emptyArr.includes(value)
}
// initialize
cacheSettings()
cacheStrings()

View File

@@ -73,9 +73,20 @@ function lang($key)
// Merge JSON data with SQL data
$mergedLanguageData = mergeLanguageData($languageData, $sqlLanguageData);
$result = $mergedLanguageData[$pia_lang_selected][$key] ?? "String Not found for key ".$key;
// Check if the key exists in the selected language
if (isset($mergedLanguageData[$pia_lang_selected][$key])) {
$result = $mergedLanguageData[$pia_lang_selected][$key];
} else {
// If key not found in selected language, use "en_us" as fallback
if (isset($mergedLanguageData['en_us'][$key])) {
$result = $mergedLanguageData['en_us'][$key];
} else {
// If key not found in "en_us" either, use a default string
$result = "String Not found for key " . $key;
}
}
return $result;
};
}

View File

@@ -26,7 +26,6 @@ last_cleanup = ''
last_update_vendors = ''
last_version_check = ''
check_report = []
log_timestamp = 0
arpscan_devices = []
# for MQTT

View File

@@ -2,6 +2,7 @@
import subprocess
import conf
import re
from helper import timeNowTZ, get_setting, get_setting_value
from scanners.internet import check_IP_format, get_internet_IP
from logger import mylog, print_log

View File

@@ -183,8 +183,6 @@ def importConfigs (db):
conf.check_report = [1, "internet_IP", "update_vendors_silent"]
conf.plugins_once_run = False
# to be deleted if not used
conf.log_timestamp = conf.time_started
#cron_instance = Cron()
# timestamps of last execution times

View File

@@ -64,10 +64,7 @@ def print_log (pText):
# log_timestamp2, ' ',
log_timestamp2.strftime ('%H:%M:%S'), ' ',
pText)
# Save current time to calculate elapsed time until next log
conf.log_timestamp = log_timestamp2
return pText