From a887f58cffd0120bdc7c96b4c35c3a92541bdb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Glawaty?= Date: Thu, 20 Jun 2024 00:57:34 +0200 Subject: [PATCH] Fixed loading of JS translation catalogues in GTM template --- gtm_template.tpl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gtm_template.tpl b/gtm_template.tpl index 787973e..14e0861 100644 --- a/gtm_template.tpl +++ b/gtm_template.tpl @@ -2376,14 +2376,19 @@ const cookieConsentWrapperScript = scriptBaseUrl + 'cookie-consent.min.js'; for (let localeKey in locales) { let locale = locales[localeKey]; + let localeScript; if (0 === locale.lastIndexOf('https://', 0) || 0 === locale.lastIndexOf('http://', 0)) { - continue; + if (-1 === locale.indexOf('.js', locale.length - 3)) { + continue; + } + + localeScript = locale; + } else { + locale = 2 < locale.length ? locale[0] + locale[1] : locale; + localeScript = scriptBaseUrl + 'translations/' + locale + '.json.js'; } - locale = 2 < locale.length ? locale[0] + locale[1] : locale; - const localeScript = scriptBaseUrl + 'translations/' + locale + '.json.js'; - if (queryPermission('inject_script', localeScript)) { injectScript(localeScript, data.gtmOnSuccess, data.gtmOnFailure); } else {