[FIX] website: prefer to get exact language
request.website.get_languages returns a list of tuple in the form: (`language code`, `language name`) With this commit the code first check if there is a language exactly matching, and only if failed check if there is a match on the short form. closes #11613 opw-672412
This commit is contained in:
parent
b6386a0a7e
commit
0c9355a8fb
|
@ -55,14 +55,14 @@ class ir_http(orm.AbstractModel):
|
||||||
|
|
||||||
def get_nearest_lang(self, lang):
|
def get_nearest_lang(self, lang):
|
||||||
# Try to find a similar lang. Eg: fr_BE and fr_FR
|
# Try to find a similar lang. Eg: fr_BE and fr_FR
|
||||||
if lang in request.website.get_languages():
|
short = lang.partition('_')[0]
|
||||||
return lang
|
short_match = False
|
||||||
|
|
||||||
short = lang.split('_')[0]
|
|
||||||
for code, name in request.website.get_languages():
|
for code, name in request.website.get_languages():
|
||||||
if code.startswith(short):
|
if code == lang:
|
||||||
return code
|
return lang
|
||||||
return False
|
if not short_match and code.startswith(short):
|
||||||
|
short_match = code
|
||||||
|
return short_match
|
||||||
|
|
||||||
def _dispatch(self):
|
def _dispatch(self):
|
||||||
first_pass = not hasattr(request, 'website')
|
first_pass = not hasattr(request, 'website')
|
||||||
|
|
Loading…
Reference in New Issue