mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Show used language, if nothing stored locally
This commit is contained in:
parent
b49ff0e5e2
commit
081e375927
@ -56,7 +56,7 @@ $(document).ready(function () {
|
|||||||
updateSessions();
|
updateSessions();
|
||||||
}); // end cmd-serverinfo
|
}); // end cmd-serverinfo
|
||||||
|
|
||||||
// Update language
|
// Update language selection
|
||||||
$("#language-select").on('changed.bs.select',function (e, clickedIndex, isSelected, previousValue){
|
$("#language-select").on('changed.bs.select',function (e, clickedIndex, isSelected, previousValue){
|
||||||
var newLang = availLang[clickedIndex-1];
|
var newLang = availLang[clickedIndex-1];
|
||||||
if (newLang !== storedLang)
|
if (newLang !== storedLang)
|
||||||
@ -64,12 +64,11 @@ $(document).ready(function () {
|
|||||||
setStorage("langcode", newLang);
|
setStorage("langcode", newLang);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#language-select").selectpicker(
|
$("#language-select").selectpicker(
|
||||||
{
|
{
|
||||||
container: 'body', title: availLangText[availLang.indexOf(getStorage("langcode"))]
|
container: 'body'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".bootstrap-select").click(function () {
|
$(".bootstrap-select").click(function () {
|
||||||
@ -84,6 +83,8 @@ $(document).ready(function () {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//End language selection
|
||||||
|
|
||||||
$(window.hyperion).on("cmd-sessions-update", function (event) {
|
$(window.hyperion).on("cmd-sessions-update", function (event) {
|
||||||
window.serverInfo.sessions = event.response.data;
|
window.serverInfo.sessions = event.response.data;
|
||||||
updateSessions();
|
updateSessions();
|
||||||
|
@ -180,13 +180,44 @@ function updateHyperionInstanceListing()
|
|||||||
|
|
||||||
function initLanguageSelection()
|
function initLanguageSelection()
|
||||||
{
|
{
|
||||||
for (var i = 0; i < availLang.length; i++)
|
// 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").append('<option value="'+i+'" selected="">'+availLangText[i]+'</option>');
|
||||||
|
}
|
||||||
|
|
||||||
$("#language-select").val(availLang.indexOf(storedLang));
|
var langLocale = storedLang;
|
||||||
$("#language-select").selectpicker("refresh");
|
|
||||||
|
// 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)
|
function updateUiOnInstance(inst)
|
||||||
|
Loading…
Reference in New Issue
Block a user