(function() { // globals MyApp.Utils = {}; // utility functions // app functions // events // app startup //configure noty Noty.overrideDefaults({ layout: 'topRight', theme: 'bootstrap-v4', closeWith: ['click', 'button'] }); // set language i18next .use(i18nextBrowserLanguageDetector) .use(i18nextXHRBackend) .init({ detection: { order: ['querystring', 'cookie', 'navigator'], lookupQuerystring: 'lang', lookupCookie: 'current-language', caches: ['cookie'], cookieMinutes: 5256000, cookieOptions: {samesite: 'lax'} }, whitelist: ['en', 'de', 'it'], load: 'languageOnly', fallbackLng: 'it', backend: { loadPath: '/i18n/{{lng}}.json' } }) .then(function() { // language initialized // if there is a lang query string parameter, remove it and reload: we save the language in a cookie so the url stays nice var urlQueryString = new URLSearchParams(window.location.search); if (urlQueryString.has('lang')) { urlQueryString.delete('lang'); var newUrl = [location.protocol, '//', location.host, location.pathname].join('') + (urlQueryString.toString() !== '' ? '?' + urlQueryString.toString() : '') + window.location.hash; window.location = newUrl; return; } // render main shell MyApp.Shell.renderShell() .then(function() { //setup routing page({ hashbang: true }); }); }); })();