Commit ebd6606f authored by Kevin Deldycke's avatar Kevin Deldycke

Thanks to recent change in the Localizer patch we can use translate() method...

Thanks to recent change in the Localizer patch we can use translate() method the old fashion way (with mapping etc.)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5415 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4fcc6a0d
...@@ -547,9 +547,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -547,9 +547,7 @@ class ListBoxWidget(Widget.Widget):
object_list = [] object_list = []
# Get translation methods # Get translation methods
localizer = portal_object.Localizer translate = portal_object.Localizer.translate
UI_ = localizer.erp5_ui.gettext
CT_ = localizer.erp5_content.gettext
# Make sure list_result_item is defined # Make sure list_result_item is defined
list_result_item = [] list_result_item = []
...@@ -1002,7 +1000,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -1002,7 +1000,7 @@ class ListBoxWidget(Widget.Widget):
stat_context.absolute_url = lambda: absolute_url_txt stat_context.absolute_url = lambda: absolute_url_txt
stat_context.domain_url = s[0].getRelativeUrl() stat_context.domain_url = s[0].getRelativeUrl()
section_title = s[0].getTitleOrId() section_title = s[0].getTitleOrId()
section_title = CT_(section_title, default=section_title.decode('utf-8')) section_title = translate('erp5_content', section_title, default=section_title.decode('utf-8'))
if type(section_title) == type(u''): if type(section_title) == type(u''):
section_title = section_title.encode('utf-8') section_title = section_title.encode('utf-8')
report_sections += [(s[0].getTitleOrId(), 1, s[2], [stat_context], 1, s[3], s[4], stat_context, 0)] report_sections += [(s[0].getTitleOrId(), 1, s[2], [stat_context], 1, s[3], s[4], stat_context, 0)]
...@@ -1181,7 +1179,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -1181,7 +1179,7 @@ class ListBoxWidget(Widget.Widget):
<td nowrap valign="middle" align="center"> <td nowrap valign="middle" align="center">
<select name="list_start" title="%s" size="1" <select name="list_start" title="%s" size="1"
onChange="submitAction(this.form,'%s/portal_selections/setPage')"> onChange="submitAction(this.form,'%s/portal_selections/setPage')">
""" % (UI_('Change Page'), REQUEST.URL1)) """ % (translate('erp5_ui', 'Change Page'), REQUEST.URL1))
else: else:
pages_list_append("""\ pages_list_append("""\
<td nowrap valign="middle" align="center"> <td nowrap valign="middle" align="center">
...@@ -1191,18 +1189,24 @@ class ListBoxWidget(Widget.Widget): ...@@ -1191,18 +1189,24 @@ class ListBoxWidget(Widget.Widget):
<td nowrap valign="middle" align="center"> <td nowrap valign="middle" align="center">
<select name="list_start" title="%s" size="1" <select name="list_start" title="%s" size="1"
onChange="submitAction(this.form,'%s/portal_selections/setPage')"> onChange="submitAction(this.form,'%s/portal_selections/setPage')">
""" % (portal_url_string, UI_('Previous Page'), """ % (portal_url_string, translate('erp5_ui', 'Previous Page'),
UI_('Change Page'), REQUEST.URL1)) translate('erp5_ui', 'Change Page'), REQUEST.URL1))
for p in range(0, total_pages): for p in range(0, total_pages):
if p == current_page: if p == current_page:
selected = 'selected' selected = 'selected'
else: else:
selected = '' selected = ''
pages_list_append('<option %s value="%s">%s</option>\n' \ pages_list_append( '<option %s value="%s">%s</option>\n' \
% (selected, % ( selected
p * lines, , p * lines
UI_('%s of %s') % (p+1, total_pages))) , translate( 'erp5_ui'
, '${page} of ${total_pages}'
, mapping = { 'page' : p+1
, 'total_pages': total_pages
}
)
)
)
if current_page == total_pages - 1: if current_page == total_pages - 1:
pages_list_append("""\ pages_list_append("""\
</select> </select>
...@@ -1218,7 +1222,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -1218,7 +1222,7 @@ class ListBoxWidget(Widget.Widget):
<input type="image" src="%s/images/1rightarrowv.png" <input type="image" src="%s/images/1rightarrowv.png"
title="%s" name="portal_selections/nextPage:method" border="0" /> title="%s" name="portal_selections/nextPage:method" border="0" />
</td> </td>
""" % (portal_url_string, UI_('Next Page'))) """ % (portal_url_string, translate('erp5_ui', 'Next Page')))
# Create the header of the table - this should probably become DTML # Create the header of the table - this should probably become DTML
# Create also View Selector which enables to switch from a view mode # Create also View Selector which enables to switch from a view mode
# to another directly from the listbox # to another directly from the listbox
...@@ -1227,13 +1231,21 @@ class ListBoxWidget(Widget.Widget): ...@@ -1227,13 +1231,21 @@ class ListBoxWidget(Widget.Widget):
format_dict = { 'portal_url_string': portal_url_string format_dict = { 'portal_url_string': portal_url_string
, 'list_action' : list_action , 'list_action' : list_action
, 'selection_name' : selection_name , 'selection_name' : selection_name
, 'field_title' : UI_(field_title) , 'field_title' : translate('erp5_ui', field_title)
, 'pages' : pages , 'pages' : pages
, 'record_number' : UI_('%s record(s)') % total_size , 'record_number' : translate( 'erp5_ui'
, 'item_number' : UI_('%s item(s) selected') % len(checked_uids) , '${number} record(s)'
, 'flat_list_title' : UI_('Flat List') , default='%s record(s)' % total_size
, 'report_tree_title': UI_('Report Tree') , mapping={'number': str(total_size)}
, 'domain_tree_title': UI_('Domain Tree') )
, 'item_number' : translate( 'erp5_ui'
, '${number} item(s) selected'
, default='%s item(s) selected' % len(checked_uids)
, mapping={'number': str(len(checked_uids))}
)
, 'flat_list_title' : translate('erp5_ui', 'Flat List')
, 'report_tree_title': translate('erp5_ui', 'Report Tree')
, 'domain_tree_title': translate('erp5_ui', 'Domain Tree')
} }
header_list = [] header_list = []
header_list_append = header_list.append header_list_append = header_list.append
...@@ -1328,8 +1340,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1328,8 +1340,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
if select: if select:
format_dict = { 'portal_url_string': portal_url_string format_dict = { 'portal_url_string': portal_url_string
, 'report_popup' : report_popup , 'report_popup' : report_popup
, 'check_all_title' : UI_('Check All') , 'check_all_title' : translate('erp5_ui', 'Check All')
, 'uncheck_all_title': UI_('Uncheck All') , 'uncheck_all_title': translate('erp5_ui', 'Uncheck All')
} }
list_header_list_append("""\ list_header_list_append("""\
<tr>%(report_popup)s <tr>%(report_popup)s
...@@ -1366,9 +1378,9 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1366,9 +1378,9 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
if cname[0] in sort_columns_id_list: if cname[0] in sort_columns_id_list:
#LOG('ListBox', 0, 'str(cname[1]) = %s, translate(\'ui\',str(cname[1])) = %s' % (repr(str(cname[1])), repr(translate('ui',str(cname[1]))))) #LOG('ListBox', 0, 'str(cname[1]) = %s, translate(\'ui\',str(cname[1])) = %s' % (repr(str(cname[1])), repr(translate('ui',str(cname[1])))))
list_header_list_append("<td class=\"Data\"><a href=\"%s/portal_selections/setSelectionQuickSortOrder?selection_name=%s&sort_on=%s\">%s</a> %s</td>\n" % list_header_list_append("<td class=\"Data\"><a href=\"%s/portal_selections/setSelectionQuickSortOrder?selection_name=%s&sort_on=%s\">%s</a> %s</td>\n" %
(here.absolute_url(),str(selection_name),cname[0],UI_(cname[1]),img)) (here.absolute_url(), str(selection_name), cname[0], translate('erp5_ui', cname[1]), img))
else: else:
list_header_list_append("<td class=\"Data\">%s</td>\n" % UI_(cname[1])) list_header_list_append("<td class=\"Data\">%s</td>\n" % translate('erp5_ui', cname[1]))
list_header_list_append("</tr>") list_header_list_append("</tr>")
list_header = ''.join(list_header_list) list_header = ''.join(list_header_list)
...@@ -1402,7 +1414,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1402,7 +1414,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
<td class="Data" width="50" align="center" valign="middle"> <td class="Data" width="50" align="center" valign="middle">
<input type="image" src="%s/images/exec16.png" title="%s" alt="Action" name="Base_doSelect:method" /> <input type="image" src="%s/images/exec16.png" title="%s" alt="Action" name="Base_doSelect:method" />
</td> </td>
""" % (report_search,portal_url_string,UI_('Action'))) # XXX Action? Is this word appropriate here? """ % (report_search,portal_url_string,translate('erp5_ui', 'Action'))) # XXX Action? Is this word appropriate here?
else: else:
list_search_append("""\ list_search_append("""\
<tr > <tr >
...@@ -1534,7 +1546,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1534,7 +1546,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
section_char = '-' section_char = '-'
list_body_append( list_body_append(
"""<td class="%s" align="left" valign="middle"><a href="portal_selections/foldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td> """<td class="%s" align="left" valign="middle"><a href="portal_selections/foldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td>
""" % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, CT_(section_name, default=section_name.decode('utf-8')))) """ % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, translate('erp5_content', section_name, default=section_name.decode('utf-8'))))
if render_format == 'list': if render_format == 'list':
...@@ -1553,7 +1565,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1553,7 +1565,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
section_char = '+' section_char = '+'
list_body_append( list_body_append(
"""<td class="%s" align="left" valign="middle"><a href="portal_selections/unfoldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td> """<td class="%s" align="left" valign="middle"><a href="portal_selections/unfoldReport?report_url=%s&form_id=%s&list_selection_name=%s">%s%s%s</a></td>
""" % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, CT_(section_name, default=section_name.decode('utf-8')))) """ % (td_css, getattr(stat_context,'domain_url',''), form.id, selection_name, '&nbsp;&nbsp;' * current_section[2], section_char, translate('erp5_content', section_name, default=section_name.decode('utf-8'))))
if render_format == 'list': if render_format == 'list':
...@@ -1735,7 +1747,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1735,7 +1747,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
key = my_field.id + '_%s' % o.uid key = my_field.id + '_%s' % o.uid
if field_errors.has_key(key): if field_errors.has_key(key):
error_css = 'Error' error_css = 'Error'
error_message = "<br/>%s" % UI_(field_errors[key].error_text) error_message = "<br/>%s" % translate('erp5_ui', field_errors[key].error_text)
# Display previous value (in case of error # Display previous value (in case of error
error_list.append(field_errors.get(key)) error_list.append(field_errors.get(key))
display_value = REQUEST.get('field_%s' % key, attribute_value) display_value = REQUEST.get('field_%s' % key, attribute_value)
......
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