Commit 41a4e883 authored by Yusei Tahara's avatar Yusei Tahara

Find preferred language from HTTP_ACCEPT_LANGUAGE, if there is no preferred language cookie.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24066 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1c733ea5
...@@ -438,10 +438,27 @@ class WizardTool(BaseTool): ...@@ -438,10 +438,27 @@ class WizardTool(BaseTool):
parameter_dict['erp5_url'] = self.getPortalObject().absolute_url() parameter_dict['erp5_url'] = self.getPortalObject().absolute_url()
# add user preffered language # add user preffered language
REQUEST = getattr(self, 'REQUEST', None) REQUEST = getattr(self, 'REQUEST', None)
configurator_user_preferred_language = 'en'
configurator_user_preferred_language = None
if REQUEST is not None: if REQUEST is not None:
# language value will be in cookie or REQUEST itself. # language value will be in cookie or REQUEST itself.
configurator_user_preferred_language = REQUEST.get(LANGUAGE_COOKIE_NAME, configurator_user_preferred_language) configurator_user_preferred_language = REQUEST.get(LANGUAGE_COOKIE_NAME, None)
if configurator_user_preferred_language is None:
# Find a preferred language from HTTP_ACCEPT_LANGUAGE
accept_language = REQUEST.get('HTTP_ACCEPT_LANGUAGE', 'en')
accept_language_tag = accept_language.split(';')[0].split(',')[0]
primary_language = accept_language_tag.split('-')[0]
configuration_language_list = [language_set[1]
for language_set in self.WizardTool_getConfigurationLanguageList()]
if primary_language in configuration_language_list:
configurator_user_preferred_language = primary_language
if configurator_user_preferred_language is None:
configurator_user_preferred_language = 'en'
parameter_dict['user_preferred_language'] = configurator_user_preferred_language parameter_dict['user_preferred_language'] = configurator_user_preferred_language
def _updateParameterDictWithFileUpload(self, parameter_dict): def _updateParameterDictWithFileUpload(self, parameter_dict):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment