summaryrefslogtreecommitdiff
path: root/odoo/http.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-03-28 14:51:14 +0200
committerChristophe Simonis <chs@odoo.com>2017-03-28 14:51:14 +0200
commit27496730d8f50105708038892dffe47c59a2d51e (patch)
tree79411b73771e6d122683513a530af3f8ac6150cf /odoo/http.py
parent0dbc8b0e58daa5e9e7e40c85ee853a062d207767 (diff)
parentc2569b9df1b0b30d69607d86e3560feb0490c4ef (diff)
[MERGE] forward port branch saas-11 up to c2569b9df1b
Diffstat (limited to 'odoo/http.py')
-rw-r--r--odoo/http.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/odoo/http.py b/odoo/http.py
index ae7e2ae5e2b..cef63e8f639 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -1366,9 +1366,16 @@ class Root(object):
httprequest.session.db = db_monodb(httprequest)
def setup_lang(self, httprequest):
- if not "lang" in httprequest.session.context:
- lang = httprequest.accept_languages.best or "en_US"
- lang = babel.core.LOCALE_ALIASES.get(lang, lang).replace('-', '_')
+ if "lang" not in httprequest.session.context:
+ alang = httprequest.accept_languages.best or "en-US"
+ try:
+ code, territory, _, _ = babel.core.parse_locale(alang, sep='-')
+ if territory:
+ lang = '%s_%s' % (code, territory)
+ else:
+ lang = babel.core.LOCALE_ALIASES[code]
+ except (ValueError, KeyError):
+ lang = 'en_US'
httprequest.session.context["lang"] = lang
def get_request(self, httprequest):