From 27d8ed7e5c31ab72f64ce04d46e0a99c4df684d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lionel=20Lask=C3=A9?= Date: Sat, 12 Aug 2023 19:23:54 +0200 Subject: [PATCH] Wait localization to launch first screen tutorial --- js/firstscreen.js | 6 +++++- lib/l10n.js | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/firstscreen.js b/js/firstscreen.js index 04d58c9e8..0bfe312b4 100644 --- a/js/firstscreen.js +++ b/js/firstscreen.js @@ -94,10 +94,14 @@ enyo.kind({ // At first launch, display tutorial var that = this; - window.setTimeout(function() { + var interval = window.setInterval(function() { if (that.history.length == 0) { + if (!l10n.initialized) { + return; + } that.startTutorial(); } + window.clearInterval(interval); }, constant.timerBeforeTutorial); }, diff --git a/lib/l10n.js b/lib/l10n.js index 8bc90285b..137554fea 100644 --- a/lib/l10n.js +++ b/lib/l10n.js @@ -1,6 +1,5 @@ define(['i18next.min', 'axios.min'], function (i18next, axios) { - const l10n = {language: {direction: "ltr"}}; - let initialized = false; + const l10n = {language: {direction: "ltr"}, initialized: false}; l10n.init = async (lang) => { await i18next.init({ @@ -38,12 +37,12 @@ define(['i18next.min', 'axios.min'], function (i18next, axios) { l10n.init("en"); } i18next.changeLanguage(lang); - initialized = true; + l10n.initialized = true; triggerLocalizedEvent(); }); } else { i18next.changeLanguage(lang); - initialized = true; + l10n.initialized = true; triggerLocalizedEvent(); } };