use directories for structure
This commit is contained in:
55
app/index.js
Normal file
55
app/index.js
Normal file
@@ -0,0 +1,55 @@
|
||||
(function() {
|
||||
// globals
|
||||
MyApp.Utils = {};
|
||||
|
||||
// utility functions
|
||||
|
||||
// app functions
|
||||
|
||||
// events
|
||||
|
||||
// app startup
|
||||
|
||||
// set language
|
||||
i18next
|
||||
.use(i18nextBrowserLanguageDetector)
|
||||
.use(i18nextXHRBackend)
|
||||
.init({
|
||||
detection: {
|
||||
order: ['querystring', 'cookie', 'navigator'],
|
||||
lookupQuerystring: 'lang',
|
||||
lookupCookie: 'current-language',
|
||||
caches: ['cookie'],
|
||||
cookieMinutes: 5256000
|
||||
},
|
||||
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
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
Reference in New Issue
Block a user