Skip to content
Snippets Groups Projects
Commit 83683246 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Modify the algorithm of get_language to extract only the primary language.

parent 48ebe0b3
No related branches found
No related tags found
No related merge requests found
......@@ -100,8 +100,8 @@ def get_js_files(server_path, client_path, directory):
def get_language(environment):
"""Helper method returning the application language.
The result is compliant with the ExtJS file name.
"""Helper method returning the application language compliant with
the ExtJS local file name.
The dictionary environment contains the keys request, response,
session, plugins, ....
......@@ -109,8 +109,11 @@ def get_language(environment):
"""
lg = environment['T'].accepted_language
if len(lg) == 5 and lg[0:2] == lg[3:5]:
lg = lg[0:2]
# HTML tag for language: primary-dialect
# Extract the primary language and ignore dialect
m = re.match('([a-z]+)(\-([a-zA-Z]*))?', lg)
if m:
return m.group(1)
return lg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment