Commit 86e5cdfc authored by Jérome Perrin's avatar Jérome Perrin

Use more Messages to allow finer grained translation of dates format

Use standard preference API and DateTime's strftime method for simplifications.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20013 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c3f8b39f
......@@ -70,28 +70,25 @@
from Products.ERP5Type.Message import Message\n
from Products.ERP5Type.Document import newTempBase\n
from string import zfill\n
portal_object = context.getPortalObject()\n
portal = context.getPortalObject()\n
request = context.REQUEST\n
domain_list = []\n
\n
selection_name = request.get(\'selection_name\')\n
selection = context.portal_selections.getSelectionFor(\n
selection_name, request)\n
params = portal.portal_selections.getSelectionParamsFor(selection_name, request)\n
\n
params = selection.getParams()\n
bound_start = DateTime(params.get(\'bound_start\', DateTime()))\n
bound_start = DateTime(bound_start.year() , bound_start.month() , bound_start.day()) \n
\n
bound_start = bound_start + params.get(\'bound_variation\', 0)\n
bound_stop = bound_start + 1\n
\n
# Definning date order using user Preference Options\n
try:\n
date_order = context.portal_preferences.getActivePreference().getPreferredDateOrder()\n
if (date_order is None) or date_order not in [ \'dmy\', \'ymd\' , \'mdy\' ]:\n
date_order = \'ymd\'\n
except AttributeError:\n
date_order = \'ymd\'\n
\n
# Define date format using user Preferences\n
date_order = portal.portal_preferences.getPreferredDateOrder()\n
date_format = dict(ymd=\'%m/%d %H:00\',\n
dmy=\'%d/%m %H:00\',\n
mdy=\'%m/%d %H:00\').get(date_order, \'%Y/%m/%d %H:00\')\n
\n
category_list = []\n
if depth == 0:\n
......@@ -100,7 +97,7 @@ if depth == 0:\n
# 0.125 means 3 hours in DateTime float format\n
while current_date < bound_stop:\n
# Create one Temp Object\n
o = newTempBase(portal_object, id=\'year\' ,uid=\'new_%s\' % zfill(\'year\',4))\n
o = newTempBase(portal, id=\'year\', uid=\'new_%s\' % zfill(\'year\',4))\n
# Setting Axis Dates start and stop\n
o.setProperty(\'start\',current_date)\n
o.setProperty(\'stop\', current_date + 0.125)\n
......@@ -112,20 +109,16 @@ if depth == 0:\n
else:\n
o.setProperty(\'delimiter_type\', 0)\n
\n
# defining date order\n
date_order_list = []\n
for i in date_order:\n
if i == \'d\': date_order_list.append(current_date.day())\n
if i == \'m\': date_order_list.append(current_date.month())\n
title = \'%s %s/%s %s:00\' % (Message(domain=\'erp5_ui\',message=current_date.Day(),\n
mapping=None),\n
str(date_order_list[0]), str(date_order_list[1]),\n
str(current_date.hour()))\n
title = Message(\'erp5_ui\',\n
\'${day_name} ${date}\',\n
mapping=dict(day_name=Message(\'erp5_ui\',\n
current_date.Day()),\n
date=current_date.strftime(date_format))).translate()\n
o.setProperty(\'title\', title)\n
tp = \'%s %s\' % (Message(domain=\'erp5_ui\', message=current_date.Day(),mapping=None), str(current_date))\n
o.setProperty(\'tooltip\', tp) \n
tp = \'%s %s\' % (Message(domain=\'erp5_ui\', message=current_date.Day()), str(current_date))\n
o.setProperty(\'tooltip\', tp)\n
\n
category_list.append(o) \n
category_list.append(o)\n
\n
current_date = current_date + 0.125\n
\n
......@@ -142,7 +135,6 @@ for category in category_list:\n
\n
domain_list.append(domain)\n
\n
context.log("%s on %s" % (script.getId(), context.getPath()), "%d objects domain" % len(domain_list))\n
return domain_list\n
......@@ -160,6 +152,10 @@ return domain_list\n
<none/>
</value>
</item>
<item>
<key> <string>_lazy_compilation</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
......@@ -205,33 +201,28 @@ return domain_list\n
<string>zfill</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_object</string>
<string>portal</string>
<string>request</string>
<string>domain_list</string>
<string>selection_name</string>
<string>selection</string>
<string>params</string>
<string>DateTime</string>
<string>bound_start</string>
<string>bound_stop</string>
<string>date_order</string>
<string>None</string>
<string>AttributeError</string>
<string>dict</string>
<string>date_format</string>
<string>category_list</string>
<string>current_date</string>
<string>o</string>
<string>int</string>
<string>date_order_list</string>
<string>_getiter_</string>
<string>i</string>
<string>str</string>
<string>_getitem_</string>
<string>title</string>
<string>str</string>
<string>tp</string>
<string>_getiter_</string>
<string>category</string>
<string>domain</string>
<string>script</string>
<string>len</string>
</tuple>
</value>
</item>
......
......@@ -73,18 +73,17 @@
from Products.ERP5Type.Message import Message\n
from Products.ERP5Type.Document import newTempBase\n
from string import zfill\n
portal_object = context.getPortalObject()\n
portal = context.getPortalObject()\n
request = context.REQUEST\n
domain_list = []\n
\n
form_id=request.get(\'form_id\')\n
selection_name = request.get(\'selection_name\')\n
selection = context.portal_selections.getSelectionFor(selection_name, request)\n
params = portal.portal_selections.getSelectionParamsFor(selection_name, request)\n
\n
params = selection.getParams()\n
zoom_variation = params.get(\'bound_variation\', 0)\n
bound_start = DateTime(params.get(\'bound_start\', DateTime()))\n
zoom_begin = DateTime(bound_start.year() , bound_start.month() , bound_start.day()) \n
zoom_begin = DateTime(bound_start.year(), bound_start.month(), bound_start.day())\n
\n
# Normalize Month.\n
month = zoom_begin.month() + zoom_variation\n
......@@ -104,22 +103,19 @@ axis_stop = DateTime(year, month, 1)\n
default_link_url =\'setLanePath?form_id=%s&list_selection_name=%s\' %(\n
form_id, selection_name)\n
\n
# Definning date order using user Preference Options\n
try:\n
date_order = context.portal_preferences.getActivePreference().getPreferredDateOrder()\n
if (date_order is None) or date_order not in [ \'dmy\', \'ymd\' , \'mdy\' ]:\n
date_order = \'ymd\'\n
except AttributeError:\n
# no Enabled preferences found.\n
date_order = \'ymd\'\n
\n
# Define date format using user Preferences\n
date_order = portal.portal_preferences.getPreferredDateOrder()\n
date_format = dict(ymd=\'%Y/%m/%d\',\n
dmy=\'%d/%m/%Y\',\n
mdy=\'%m/%d/%Y\').get(date_order, \'%Y/%m/%d\')\n
\n
category_list = []\n
if depth == 0: \n
if depth == 0:\n
# recovering first date displayed, without time:\n
while current_date < axis_stop: \n
while current_date < axis_stop: \n
# Create one Temp Object\n
o = newTempBase(portal_object, id=str(current_date.Day()) ,uid=\'new_%s\' % zfill(\'year\',4))\n
o = newTempBase(portal, id=str(current_date.Day()),\n
uid=\'new_%s\' % zfill(\'year\',4))\n
\n
# Setting Axis Dates start and stop\n
o.setProperty(\'start\',current_date)\n
......@@ -132,15 +128,9 @@ if depth == 0: \n
else:\n
o.setProperty(\'delimiter_type\', 0)\n
\n
date_order_list = []\n
for i in date_order:\n
if i == \'d\': date_order_list.append(current_date.day())\n
if i == \'m\': date_order_list.append(current_date.month())\n
if i == \'y\': date_order_list.append(current_date.year())\n
\n
o.setProperty(\'title\', \'%s/%s/%s\' % (str(date_order_list[0]), str(date_order_list[1]),str(date_order_list[2])))\n
tp = \'%s %s\' % (Message(domain=\'erp5_ui\', message=current_date.Day(),mapping=None), str(current_date))\n
o.setProperty(\'tooltip\', tp) \n
o.setProperty(\'title\', current_date.strftime(date_format))\n
tp = \'%s %s\' % (Message(domain=\'erp5_ui\', message=current_date.Day(), mapping=None), str(current_date))\n
o.setProperty(\'tooltip\', tp)\n
\n
link = \'%s&bound_start=%s&lane_path=base_week_domain\' % ( default_link_url, current_date)\n
o.setProperty(\'link\', link) \n
......@@ -162,7 +152,6 @@ for category in category_list:\n
\n
domain_list.append(domain)\n
\n
#context.log("%s on %s" % (script.getId(), context.getPath()), "%d objects domain" % len(domain_list))\n
return domain_list\n
......@@ -180,6 +169,10 @@ return domain_list\n
<none/>
</value>
</item>
<item>
<key> <string>_lazy_compilation</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
......@@ -225,12 +218,11 @@ return domain_list\n
<string>zfill</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_object</string>
<string>portal</string>
<string>request</string>
<string>domain_list</string>
<string>form_id</string>
<string>selection_name</string>
<string>selection</string>
<string>params</string>
<string>zoom_variation</string>
<string>DateTime</string>
......@@ -242,18 +234,16 @@ return domain_list\n
<string>axis_stop</string>
<string>default_link_url</string>
<string>date_order</string>
<string>None</string>
<string>AttributeError</string>
<string>dict</string>
<string>date_format</string>
<string>category_list</string>
<string>str</string>
<string>o</string>
<string>int</string>
<string>date_order_list</string>
<string>_getiter_</string>
<string>i</string>
<string>_getitem_</string>
<string>None</string>
<string>tp</string>
<string>link</string>
<string>_getiter_</string>
<string>category</string>
<string>domain</string>
<string>script</string>
......
......@@ -74,21 +74,19 @@ from Products.ERP5Type.Message import Message\n
from Products.ERP5Type.Document import newTempBase\n
from string import zfill\n
\n
portal_object = context.getPortalObject()\n
portal = context.getPortalObject()\n
request = context.REQUEST\n
domain_list = []\n
form_id=request.get(\'form_id\')\n
\n
selection_name = request.get(\'selection_name\')\n
selection = context.portal_selections.getSelectionFor(\n
selection_name, request)\n
params = context.portal_selections.getSelectionParamsFor(selection_name, request)\n
\n
params = selection.getParams()\n
bound_variation = params.get(\'bound_variation\', 0)\n
bound_start = DateTime(params.get(\'bound_start\', DateTime()))\n
bound_start = DateTime(bound_start.year() , bound_start.month() , bound_start.day()) \n
bound_start = DateTime(bound_start.year() , bound_start.month() , bound_start.day())\n
\n
# Normalize Week.\n
# Normalize Week. XXX this should be in preferences as well\n
while bound_start.Day() is not \'Sunday\':\n
bound_start = bound_start - 1\n
current_date = bound_start + 7 * bound_variation\n
......@@ -97,20 +95,18 @@ bound_stop = current_date + 7\n
default_link_url =\'setLanePath?form_id=%s&list_selection_name=%s\' %(\n
form_id, selection_name)\n
\n
# Definning date order using user Preference Options\n
try:\n
date_order = context.portal_preferences.getActivePreference().getPreferredDateOrder()\n
if (date_order is None) or date_order not in [ \'dmy\', \'ymd\' , \'mdy\' ]:\n
date_order = \'ymd\'\n
except AttributeError:\n
date_order = \'ymd\'\n
# Define date format using user Preferences\n
date_order = portal.portal_preferences.getPreferredDateOrder()\n
date_format = dict(ymd=\'%Y/%m/%d\',\n
dmy=\'%d/%m/%Y\',\n
mdy=\'%m/%d/%Y\').get(date_order, \'%Y/%m/%d\')\n
\n
category_list = []\n
if depth == 0: \n
if depth == 0:\n
# This case show Seven days\n
while current_date < bound_stop:\n
# Create one Temp Object\n
o = newTempBase(portal_object, id=\'week\' ,uid=\'new_%s\' % zfill(\'week\',4))\n
o = newTempBase(portal, id=\'week\', uid=\'new_%s\' % zfill(\'week\',4))\n
# Setting Axis Dates start and stop\n
o.setProperty(\'start\',current_date)\n
o.setProperty(\'stop\', current_date+1)\n
......@@ -124,28 +120,22 @@ if depth == 0: \n
else:\n
o.setProperty(\'delimiter_type\', 0)\n
\n
# defining date order\n
date_order_list = []\n
for i in date_order:\n
if i == \'d\': date_order_list.append(current_date.day())\n
if i == \'m\': date_order_list.append(current_date.month())\n
if i == \'y\': date_order_list.append(current_date.year())\n
\n
title = \'%s %s/%s/%s\' % (Message(domain=\'erp5_ui\', message=current_date.Day(), mapping=None),\n
str(date_order_list[0]), \n
str(date_order_list[1]),\n
str(date_order_list[2]))\n
title = Message(\'erp5_ui\',\n
\'${day_name} ${date}\',\n
mapping=dict(day_name=Message(\'erp5_ui\',\n
current_date.Day()),\n
date=current_date.strftime(date_format))).translate()\n
o.setProperty(\'title\', title)\n
\n
# Defining ToolTip (Optional)\n
tp = \'%s %s\' % (Message(domain=\'erp5_ui\', message=current_date.Day(),mapping=None), str(current_date))\n
o.setProperty(\'tooltip\', tp) \n
tp = \'%s %s\' % (Message(domain=\'erp5_ui\', message=current_date.Day()), str(current_date))\n
o.setProperty(\'tooltip\', tp)\n
\n
# Defining Link (Optional)\n
link = \'%s&bound_start=%s&lane_path=base_day_domain\' % ( default_link_url, current_date)\n
o.setProperty(\'link\', link) \n
o.setProperty(\'link\', link)\n
\n
category_list.append(o) \n
category_list.append(o)\n
current_date = current_date + 1\n
else:\n
return domain_list\n
......@@ -177,6 +167,10 @@ return domain_list\n
<none/>
</value>
</item>
<item>
<key> <string>_lazy_compilation</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
......@@ -222,12 +216,11 @@ return domain_list\n
<string>zfill</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_object</string>
<string>portal</string>
<string>request</string>
<string>domain_list</string>
<string>form_id</string>
<string>selection_name</string>
<string>selection</string>
<string>params</string>
<string>bound_variation</string>
<string>DateTime</string>
......@@ -236,19 +229,16 @@ return domain_list\n
<string>bound_stop</string>
<string>default_link_url</string>
<string>date_order</string>
<string>None</string>
<string>AttributeError</string>
<string>dict</string>
<string>date_format</string>
<string>category_list</string>
<string>o</string>
<string>int</string>
<string>date_order_list</string>
<string>_getiter_</string>
<string>i</string>
<string>str</string>
<string>_getitem_</string>
<string>title</string>
<string>str</string>
<string>tp</string>
<string>link</string>
<string>_getiter_</string>
<string>category</string>
<string>domain</string>
<string>script</string>
......
......@@ -74,16 +74,14 @@ from Products.ERP5Type.Message import Message\n
from Products.ERP5Type.Document import newTempBase\n
from string import zfill\n
\n
portal_object = context.getPortalObject()\n
portal = context.getPortalObject()\n
request = context.REQUEST\n
domain_list = []\n
form_id=request.get(\'form_id\')\n
\n
selection_name = request.get(\'selection_name\')\n
selection = context.portal_selections.getSelectionFor(\n
selection_name, request)\n
params = portal.portal_selections.getSelectionParamsFor(selection_name, request)\n
\n
params = selection.getParams()\n
zoom_begin = DateTime(params.get(\'bound_start\', DateTime()))\n
year = zoom_begin.year() + params.get(\'bound_variation\', 0)\n
current_date = DateTime(year, 1, 1)\n
......@@ -91,22 +89,19 @@ current_date = DateTime(year, 1, 1)\n
default_link_url =\'setLanePath?form_id=%s&list_selection_name=%s\' %(\n
form_id, selection_name)\n
\n
# Definning date order using user Preference Options\n
try:\n
date_order = context.portal_preferences.getActivePreference().getPreferredDateOrder()\n
if (date_order is None) or date_order not in [ \'dmy\', \'ymd\' , \'mdy\' ]:\n
date_order = \'ymd\'\n
except AttributeError:\n
date_order = \'ymd\'\n
\n
# Define date format using user Preferences\n
date_order = portal.portal_preferences.getPreferredDateOrder()\n
date_format = dict(ymd=\'%m/%d\',\n
dmy=\'%d/%m\',\n
mdy=\'%m/%d\').get(date_order, \'%m/%d\')\n
\n
category_list = []\n
if depth == 0: \n
if depth == 0:\n
# getting list of months\n
count = 0\n
while count < 12:\n
# Create one Temp Object\n
o = newTempBase(portal_object, id=\'year\' ,uid=\'new_%s\' % zfill(\'year\',4))\n
o = newTempBase(portal, id=\'year\' ,uid=\'new_%s\' % zfill(\'year\',4))\n
# Seting delimiter \n
if current_date.month() in [1, 7]:\n
o.setProperty(\'delimiter_type\', 1)\n
......@@ -123,22 +118,18 @@ if depth == 0: \n
\n
o.setProperty(\'relative_position\', int(current_date))\n
\n
date_order_list = []\n
for i in date_order:\n
if i == \'m\': date_order_list.append(current_date.month())\n
if i == \'y\': date_order_list.append(current_date.year())\n
\n
o.setProperty(\'title\', str(date_order_list[0]) + \'/\' + str(date_order_list[1]))\n
\n
# Defining ToolTip (Optional)\n
tp = \'%s %s\' % (Message(domain=\'erp5_ui\', message=current_date.Day(),mapping=None), str(current_date))\n
o.setProperty(\'tooltip\', tp)\n
title = Message(\'erp5_ui\',\n
\'${month_name} ${year}\',\n
mapping=dict(month_name=Message(\'erp5_ui\',\n
current_date.Month()),\n
year=str(current_date.year()))).translate()\n
o.setProperty(\'title\', title)\n
\n
# Defining Link\n
link = \'%s&bound_start=%s&lane_path=base_month_domain\' % ( default_link_url, current_date)\n
o.setProperty(\'link\', link) \n
o.setProperty(\'link\', link)\n
\n
category_list.append(o) \n
category_list.append(o)\n
current_date = DateTime(str(current_date.year()) + \'/\' + str((current_date.month() +1)) + \'/1\')\n
count += 1\n
else:\n
......@@ -171,6 +162,10 @@ return domain_list\n
<none/>
</value>
</item>
<item>
<key> <string>_lazy_compilation</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
......@@ -216,12 +211,11 @@ return domain_list\n
<string>zfill</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_object</string>
<string>portal</string>
<string>request</string>
<string>domain_list</string>
<string>form_id</string>
<string>selection_name</string>
<string>selection</string>
<string>params</string>
<string>DateTime</string>
<string>zoom_begin</string>
......@@ -229,21 +223,18 @@ return domain_list\n
<string>current_date</string>
<string>default_link_url</string>
<string>date_order</string>
<string>None</string>
<string>AttributeError</string>
<string>dict</string>
<string>date_format</string>
<string>category_list</string>
<string>count</string>
<string>o</string>
<string>stop_date</string>
<string>int</string>
<string>date_order_list</string>
<string>_getiter_</string>
<string>i</string>
<string>str</string>
<string>_getitem_</string>
<string>tp</string>
<string>title</string>
<string>link</string>
<string>_inplacevar_</string>
<string>_getiter_</string>
<string>category</string>
<string>domain</string>
<string>script</string>
......
752
\ No newline at end of file
753
\ No newline at end of file
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