Show used language, if nothing stored locally

This commit is contained in:
LordGrey
2020-05-30 16:40:51 +02:00
parent b49ff0e5e2
commit 081e375927
2 changed files with 42 additions and 10 deletions

View File

@@ -180,13 +180,44 @@ function updateHyperionInstanceListing()
function initLanguageSelection()
{
for (var i = 0; i < availLang.length; i++)
{
$("#language-select").append('<option value="'+i+'" selected="">'+availLangText[i]+'</option>');
}
// Initialise language selection list with languages supported
for (var i = 0; i < availLang.length; i++)
{
$("#language-select").append('<option value="'+i+'" selected="">'+availLangText[i]+'</option>');
}
$("#language-select").val(availLang.indexOf(storedLang));
$("#language-select").selectpicker("refresh");
var langLocale = storedLang;
// If no language has been set, resolve browser locale
if ( langLocale === 'auto' )
{
langLocale = $.i18n().locale.substring(0,2);
}
// Resolve text for language code
var langText = 'Please Select';
//Test, if language is supported by hyperion
langIdx = availLang.indexOf(langLocale)
if ( langIdx > -1 )
{
langText = availLangText[langIdx];
}
else
{
// If language is not supported by hyperion, try fallback language
langLocale = $.i18n().options.fallbackLocale.substring(0,2);
langIdx = availLang.indexOf(langLocale)
if ( langIdx > -1 )
{
langText = availLangText[langIdx];
}
}
//console.log("langLocale: ", langLocale, "langText: ", langText);
$('#language-select').prop('title', langText);
$("#language-select").val(langIdx);
$("#language-select").selectpicker("refresh");
}
function updateUiOnInstance(inst)