forked from 0x2620/pandora
dont set default locale in user.ui and use first browser locale by default if available and fall back to site default after that, fixes #1578; load locale from unjoined json files in debug mode
This commit is contained in:
parent
24afe66c75
commit
5489823a61
7 changed files with 29 additions and 10 deletions
|
@ -154,6 +154,8 @@ def init(request):
|
||||||
config = copy.deepcopy(settings.CONFIG)
|
config = copy.deepcopy(settings.CONFIG)
|
||||||
del config['keys']
|
del config['keys']
|
||||||
|
|
||||||
|
if 'HTTP_ACCEPT_LANGUAGE' in request.META:
|
||||||
|
response['data']['locale'] = request.META['HTTP_ACCEPT_LANGUAGE'].split(';')[0].split('-')[0]
|
||||||
response['data']['site'] = config
|
response['data']['site'] = config
|
||||||
response['data']['user'] = init_user(request.user, request)
|
response['data']['user'] = init_user(request.user, request)
|
||||||
request.session['last_init'] = str(datetime.now())
|
request.session['last_init'] = str(datetime.now())
|
||||||
|
|
|
@ -716,6 +716,7 @@
|
||||||
"system": "0xDB@0xDB.org"
|
"system": "0xDB@0xDB.org"
|
||||||
},
|
},
|
||||||
"https": true,
|
"https": true,
|
||||||
|
"locale": "en",
|
||||||
"id": "0xdb",
|
"id": "0xdb",
|
||||||
"name": "0xDB",
|
"name": "0xDB",
|
||||||
"url": "0xDB.org",
|
"url": "0xDB.org",
|
||||||
|
@ -803,7 +804,7 @@
|
||||||
"listSort": [{"key": "director", "operator": "+"}],
|
"listSort": [{"key": "director", "operator": "+"}],
|
||||||
"listView": "grid",
|
"listView": "grid",
|
||||||
"lists": {},
|
"lists": {},
|
||||||
"locale": "en",
|
"locale": "",
|
||||||
"mapFind": "",
|
"mapFind": "",
|
||||||
"mapSelection": "",
|
"mapSelection": "",
|
||||||
"page": "",
|
"page": "",
|
||||||
|
|
|
@ -729,6 +729,7 @@
|
||||||
},
|
},
|
||||||
"folderdepth": 4,
|
"folderdepth": 4,
|
||||||
"https": true,
|
"https": true,
|
||||||
|
"locale": "en",
|
||||||
"id": "indiancinema",
|
"id": "indiancinema",
|
||||||
"name": "Indiancine.ma",
|
"name": "Indiancine.ma",
|
||||||
"url": "indiancine.ma",
|
"url": "indiancine.ma",
|
||||||
|
@ -815,7 +816,7 @@
|
||||||
"listSort": [{"key": "year", "operator": "+"}],
|
"listSort": [{"key": "year", "operator": "+"}],
|
||||||
"listView": "grid",
|
"listView": "grid",
|
||||||
"lists": {},
|
"lists": {},
|
||||||
"locale": "en",
|
"locale": "",
|
||||||
"mapFind": "",
|
"mapFind": "",
|
||||||
"mapSelection": "",
|
"mapSelection": "",
|
||||||
"page": "",
|
"page": "",
|
||||||
|
|
|
@ -607,6 +607,7 @@
|
||||||
"system": "system@pad.ma"
|
"system": "system@pad.ma"
|
||||||
},
|
},
|
||||||
"https": true,
|
"https": true,
|
||||||
|
"locale": "en",
|
||||||
"id": "padma",
|
"id": "padma",
|
||||||
"name": "Pad.ma",
|
"name": "Pad.ma",
|
||||||
"url": "pad.ma",
|
"url": "pad.ma",
|
||||||
|
@ -693,7 +694,7 @@
|
||||||
"listSort": [{"key": "title", "operator": "+"}],
|
"listSort": [{"key": "title", "operator": "+"}],
|
||||||
"listView": "grid",
|
"listView": "grid",
|
||||||
"lists": {},
|
"lists": {},
|
||||||
"locale": "en",
|
"locale": "",
|
||||||
"mapFind": "",
|
"mapFind": "",
|
||||||
"mapSelection": "",
|
"mapSelection": "",
|
||||||
"page": "",
|
"page": "",
|
||||||
|
|
|
@ -527,6 +527,7 @@
|
||||||
},
|
},
|
||||||
"https": false,
|
"https": false,
|
||||||
"id": "pandora",
|
"id": "pandora",
|
||||||
|
"locale": "en",
|
||||||
"name": "Demo",
|
"name": "Demo",
|
||||||
"url": "pandora.local",
|
"url": "pandora.local",
|
||||||
"videoprefix": ""
|
"videoprefix": ""
|
||||||
|
@ -612,7 +613,7 @@
|
||||||
"listSort": [{"key": "title", "operator": "+"}],
|
"listSort": [{"key": "title", "operator": "+"}],
|
||||||
"listView": "grid",
|
"listView": "grid",
|
||||||
"lists": {},
|
"lists": {},
|
||||||
"locale": "en",
|
"locale": "",
|
||||||
"mapFind": "",
|
"mapFind": "",
|
||||||
"mapSelection": "",
|
"mapSelection": "",
|
||||||
"page": "",
|
"page": "",
|
||||||
|
|
|
@ -327,7 +327,8 @@ appPanel
|
||||||
});
|
});
|
||||||
|
|
||||||
// set locale and initialize url controller
|
// set locale and initialize url controller
|
||||||
pandora.setLocale(pandora.user.ui.locale, function() {
|
// data.locale
|
||||||
|
pandora.setLocale(pandora.user.ui.locale || data.locale, function() {
|
||||||
pandora.URL.init().parse(function() {
|
pandora.URL.init().parse(function() {
|
||||||
var isHome = Ox.contains(['/', '/home'], document.location.pathname);
|
var isHome = Ox.contains(['/', '/home'], document.location.pathname);
|
||||||
if (data.browserSupported) {
|
if (data.browserSupported) {
|
||||||
|
|
|
@ -1734,11 +1734,23 @@ pandora.selectList = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.setLocale = function(locale, callback) {
|
pandora.setLocale = function(locale, callback) {
|
||||||
Ox.setLocale(
|
var url;
|
||||||
locale,
|
// language from http header might not be supported,
|
||||||
locale && locale != 'en' ? '/static/json/locale.' + locale + '.json' : null,
|
// fall back to site default
|
||||||
callback
|
if (Ox.isUndefined(Ox.LOCALE_NAMES[locale])) {
|
||||||
);
|
locale = pandora.site.site.locale;
|
||||||
|
}
|
||||||
|
if (locale != 'en') {
|
||||||
|
if (pandora.localStorage('enableDebugMode')) {
|
||||||
|
url = [
|
||||||
|
'/static/json/locale.pandora.' + locale + '.json',
|
||||||
|
'/static/json/locale.' + pandora.site.site.id + '.' + locale + '.json',
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
url = '/static/json/locale.' + locale + '.json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ox.setLocale(locale, url, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.unloadWindow = function() {
|
pandora.unloadWindow = function() {
|
||||||
|
|
Loading…
Reference in a new issue