Add i18n support to tours

This commit is contained in:
Nick O'Leary
2021-09-27 17:34:30 +01:00
parent e9e03c945b
commit ad542b91fa
2 changed files with 27 additions and 18 deletions

View File

@@ -164,6 +164,15 @@ RED.tourGuide = (function() {
}
finish();
}
function getLocaleText(property) {
if (typeof property === 'string') {
return property;
}
var currentLang = RED.i18n.lang() || 'en-US';
var availableLangs = Object.keys(property);
return property[currentLang]||property['en-US']||property[availableLangs[0]]
}
function runTourStep(step, state, done) {
shade.fadeIn();
@@ -214,9 +223,9 @@ RED.tourGuide = (function() {
$('<h2><i class="'+step.titleIcon+'"></i></h2>').appendTo(stepDescription);
}
if (step.title) {
$('<h2>').text(step.title).appendTo(stepDescription);
$('<h2>').text(getLocaleText(step.title)).appendTo(stepDescription);
}
$('<div>').css("text-align","left").html(step.description).appendTo(stepDescription);
$('<div>').css("text-align","left").html(getLocaleText(step.description)).appendTo(stepDescription);
var stepToolbar = $('<div>',{class:"red-ui-tourGuide-toolbar"}).appendTo(stepContent);