From 83683246484583af6623d07e0786a6504d6ae553 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Tue, 5 Apr 2011 20:44:01 +0000 Subject: [PATCH] Modify the algorithm of get_language to extract only the primary language. --- modules/plugin_dbui/helper.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/plugin_dbui/helper.py b/modules/plugin_dbui/helper.py index 8cbea4fe..0d128eb0 100644 --- a/modules/plugin_dbui/helper.py +++ b/modules/plugin_dbui/helper.py @@ -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 -- GitLab