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:
j 2013-07-17 10:24:22 +00:00
parent 24afe66c75
commit 5489823a61
7 changed files with 29 additions and 10 deletions

View file

@ -154,6 +154,8 @@ def init(request):
config = copy.deepcopy(settings.CONFIG)
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']['user'] = init_user(request.user, request)
request.session['last_init'] = str(datetime.now())

View file

@ -716,6 +716,7 @@
"system": "0xDB@0xDB.org"
},
"https": true,
"locale": "en",
"id": "0xdb",
"name": "0xDB",
"url": "0xDB.org",
@ -803,7 +804,7 @@
"listSort": [{"key": "director", "operator": "+"}],
"listView": "grid",
"lists": {},
"locale": "en",
"locale": "",
"mapFind": "",
"mapSelection": "",
"page": "",

View file

@ -729,6 +729,7 @@
},
"folderdepth": 4,
"https": true,
"locale": "en",
"id": "indiancinema",
"name": "Indiancine.ma",
"url": "indiancine.ma",
@ -815,7 +816,7 @@
"listSort": [{"key": "year", "operator": "+"}],
"listView": "grid",
"lists": {},
"locale": "en",
"locale": "",
"mapFind": "",
"mapSelection": "",
"page": "",

View file

@ -607,6 +607,7 @@
"system": "system@pad.ma"
},
"https": true,
"locale": "en",
"id": "padma",
"name": "Pad.ma",
"url": "pad.ma",
@ -693,7 +694,7 @@
"listSort": [{"key": "title", "operator": "+"}],
"listView": "grid",
"lists": {},
"locale": "en",
"locale": "",
"mapFind": "",
"mapSelection": "",
"page": "",

View file

@ -527,6 +527,7 @@
},
"https": false,
"id": "pandora",
"locale": "en",
"name": "Demo",
"url": "pandora.local",
"videoprefix": ""
@ -612,7 +613,7 @@
"listSort": [{"key": "title", "operator": "+"}],
"listView": "grid",
"lists": {},
"locale": "en",
"locale": "",
"mapFind": "",
"mapSelection": "",
"page": "",

View file

@ -327,7 +327,8 @@ appPanel
});
// 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() {
var isHome = Ox.contains(['/', '/home'], document.location.pathname);
if (data.browserSupported) {

View file

@ -1734,11 +1734,23 @@ pandora.selectList = function() {
};
pandora.setLocale = function(locale, callback) {
Ox.setLocale(
locale,
locale && locale != 'en' ? '/static/json/locale.' + locale + '.json' : null,
callback
);
var url;
// language from http header might not be supported,
// fall back to site default
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() {