[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):
|
||||
# Try to find a similar lang. Eg: fr_BE and fr_FR
|
||||
if lang in request.website.get_languages():
|
||||
return lang
|
||||
|
||||
short = lang.split('_')[0]
|
||||
short = lang.partition('_')[0]
|
||||
short_match = False
|
||||
for code, name in request.website.get_languages():
|
||||
if code.startswith(short):
|
||||
return code
|
||||
return False
|
||||
if code == lang:
|
||||
return lang
|
||||
if not short_match and code.startswith(short):
|
||||
short_match = code
|
||||
return short_match
|
||||
|
||||
def _dispatch(self):
|
||||
first_pass = not hasattr(request, 'website')
|
||||
|
|
Loading…
Reference in New Issue