From f0005f3c67bf59366df3548500639bf35fe124e2 Mon Sep 17 00:00:00 2001 From: Tobias Bachmann Date: Wed, 18 Dec 2024 18:02:12 +0100 Subject: [PATCH] fix/cookie-lang-prefs: add error handling and default return Edirom Online failed if no cookie 'edirom-language' was set because pref 'application_language' was called before preferences were set. this commit is a quick fix, which returns default lang 'en' if 'application_language' could not be found. * also removing cookie-handling for 'edirom_language' Refs #504 --- app/controller/LanguageController.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controller/LanguageController.js b/app/controller/LanguageController.js index 6df3c0039..1b8e1303a 100644 --- a/app/controller/LanguageController.js +++ b/app/controller/LanguageController.js @@ -77,9 +77,16 @@ Ext.define('EdiromOnline.controller.LanguageController', { }, getLanguage: function() { - if(window.getCookie('edirom-language') !== '') - return window.getCookie('edirom-language'); - - return getPreference('application_language'); + /* since removing the cookie, this throws an error because 'application_language' is called before it is defined. + * see issue #504 + * this is a quick fix, language / preferences handling needs some rework + */ + try { + return getPreference('application_language'); + } + catch (err) { + console.log('"application_language" not found, using "en" as default.\n'); + return 'en' + } } }); \ No newline at end of file