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

@ -56,7 +56,7 @@ $(document).ready(function () {
updateSessions();
}); // end cmd-serverinfo
// Update language
// Update language selection
$("#language-select").on('changed.bs.select',function (e, clickedIndex, isSelected, previousValue){
var newLang = availLang[clickedIndex-1];
if (newLang !== storedLang)
@ -64,12 +64,11 @@ $(document).ready(function () {
setStorage("langcode", newLang);
reload();
}
});
$("#language-select").selectpicker(
{
container: 'body', title: availLangText[availLang.indexOf(getStorage("langcode"))]
container: 'body'
});
$(".bootstrap-select").click(function () {
@ -83,7 +82,9 @@ $(document).ready(function () {
$(".bootstrap-select").click(function(e){
e.stopPropagation();
});
//End language selection
$(window.hyperion).on("cmd-sessions-update", function (event) {
window.serverInfo.sessions = event.response.data;
updateSessions();

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)