Commit 528274a6 authored by Yusei Tahara's avatar Yusei Tahara

2008-10-2 yusei

* Use cookie to store user's preferred language.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23981 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4cf1ed8e
...@@ -53,16 +53,20 @@ ...@@ -53,16 +53,20 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>configuration_language_list = []\n <value> <string>REQUEST = context.REQUEST\n
user_preferred_language = getattr(context, \'user_preferred_language\', None)\n \n
# First, find a cookie already made before.\n
COOKIE_NAME = \'configurator_user_preferred_language\'\n
user_preferred_language = REQUEST.cookies.get(COOKIE_NAME, None)\n
if user_preferred_language is not None:\n if user_preferred_language is not None:\n
# user already have explicitly selected language\n # user already have explicitly selected language\n
return user_preferred_language \n return user_preferred_language\n
\n \n
# use language from browser\'s settings\n # use language from browser\'s settings\n
configuration_language_list = []\n
for item in context.WizardTool_getConfigurationLanguageList():\n for item in context.WizardTool_getConfigurationLanguageList():\n
configuration_language_list.append(item[1])\n configuration_language_list.append(item[1])\n
accept_language = context.REQUEST.get(\'HTTP_ACCEPT_LANGUAGE\', \'en\')\n accept_language = REQUEST.get(\'HTTP_ACCEPT_LANGUAGE\', \'en\')\n
accept_language_tag = accept_language.split(\';\')[0].split(\',\')[0]\n accept_language_tag = accept_language.split(\';\')[0].split(\',\')[0]\n
primary_language = accept_language_tag.split(\'-\')[0]\n primary_language = accept_language_tag.split(\'-\')[0]\n
if primary_language in configuration_language_list:\n if primary_language in configuration_language_list:\n
...@@ -104,13 +108,14 @@ return \'en\'\n ...@@ -104,13 +108,14 @@ return \'en\'\n
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>configuration_language_list</string> <string>_getattr_</string>
<string>getattr</string>
<string>context</string> <string>context</string>
<string>REQUEST</string>
<string>COOKIE_NAME</string>
<string>None</string> <string>None</string>
<string>user_preferred_language</string> <string>user_preferred_language</string>
<string>configuration_language_list</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>_getattr_</string>
<string>item</string> <string>item</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>accept_language</string> <string>accept_language</string>
......
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