From 9e255969f30cf3ea4b9cc7cf7ff307181dc1cd43 Mon Sep 17 00:00:00 2001 From: richard Date: Sat, 5 Jan 2002 02:35:10 +0000 Subject: [PATCH] I18N'ification git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@500 57a73879-2fb5-44c3-a270-3262357dd7e2 --- I18N_PROGRESS.txt | 2 +- roundup/htmltemplate.py | 100 ++++++++++++++++++++++------------------ 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/I18N_PROGRESS.txt b/I18N_PROGRESS.txt index dad31c0..9b2b972 100644 --- a/I18N_PROGRESS.txt +++ b/I18N_PROGRESS.txt @@ -17,7 +17,6 @@ whether there is at least one use of "_()". THESE FILES DO NOT USE _() ========================== -roundup/htmltemplate.py roundup/hyperdb.py roundup/i18n.py roundup/init.py @@ -59,6 +58,7 @@ roundup/cgi_client.py roundup/admin.py roundup/cgitb.py roundup/date.py +roundup/htmltemplate.py WE DON'T CARE ABOUT THESE FILES diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index f0d12d4..28f4f40 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.49 2001-12-20 15:43:01 rochecompaan Exp $ +# $Id: htmltemplate.py,v 1.50 2002-01-05 02:35:10 richard Exp $ __doc__ = """ Template engine. @@ -24,6 +24,7 @@ Template engine. import os, re, StringIO, urllib, cgi, errno import hyperdb, date, password +from i18n import _ # This imports the StructureText functionality for the do_stext function # get it from http://dev.zope.org/Members/jim/StructuredTextWiki/NGReleases @@ -52,7 +53,7 @@ class TemplateFunctions: linked nodes (or the ids if the linked class has no key property) ''' if not self.nodeid and self.form is None: - return '[Field: not called from item]' + return _('[Field: not called from item]') propclass = self.properties[property] if self.nodeid: # make sure the property is a valid one @@ -76,7 +77,7 @@ class TemplateFunctions: else: value = str(value) elif isinstance(propclass, hyperdb.Password): if value is None: value = '' - else: value = '*encrypted*' + else: value = _('*encrypted*') elif isinstance(propclass, hyperdb.Date): value = str(value) elif isinstance(propclass, hyperdb.Interval): @@ -85,7 +86,7 @@ class TemplateFunctions: linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() if value: value = str(linkcl.get(value, k)) - else: value = '[unselected]' + else: value = _('[unselected]') elif isinstance(propclass, hyperdb.Multilink): linkcl = self.db.classes[propclass.classname] k = linkcl.labelprop() @@ -158,7 +159,7 @@ class TemplateFunctions: s = 'selected ' else: s = '' - l.append(''%s) + l.append(_('')%s) options = linkcl.list() options.sort(sortfunc) for optionid in options: @@ -197,7 +198,7 @@ class TemplateFunctions: size, ','.join(input_value))) s = "
\n".join(l) else: - s = 'Plain: bad propclass "%s"'%propclass + s = _('Plain: bad propclass "%(propclass)s"')%locals() return s def do_menu(self, property, size=None, height=None, showid=0): @@ -217,7 +218,7 @@ class TemplateFunctions: s = '' if value is None: s = 'selected ' - l.append(''%s) + l.append(_('')%s) for optionid in linkcl.list(): option = linkcl.get(optionid, k) s = '' @@ -246,7 +247,7 @@ class TemplateFunctions: l.append(''%(s, optionid, option)) l.append('') return '\n'.join(l) - return '[Menu: not a link]' + return _('[Menu: not a link]') #XXX deviates from spec def do_link(self, property=None, is_download=0): @@ -260,7 +261,7 @@ class TemplateFunctions: downloaded file name is correct. ''' if not self.nodeid and self.form is None: - return '[Link: not called from item]' + return _('[Link: not called from item]') propclass = self.properties[property] if self.nodeid: value = self.cl.get(self.nodeid, property) @@ -283,7 +284,8 @@ class TemplateFunctions: linkname = propclass.classname linkcl = self.db.classes[linkname] k = linkcl.labelprop() - if not value : return '[no %s]'%property.capitalize() + if not value: + return _('[no %(propname)s]')%{'propname': property.capitalize()} l = [] for value in value: linkvalue = linkcl.get(value, k) @@ -294,8 +296,8 @@ class TemplateFunctions: l.append('%s'%(linkname, value, linkvalue)) return ', '.join(l) - if isinstance(propclass, hyperdb.String): - if value == '': value = '[no %s]'%property.capitalize() + if isinstance(propclass, hyperdb.String) and value == '': + return _('[no %(propname)s]')%{'propname': property.capitalize()} if is_download: return '%s'%(self.classname, self.nodeid, value, value) @@ -307,12 +309,12 @@ class TemplateFunctions: the list ''' if not self.nodeid: - return '[Count: not called from item]' + return _('[Count: not called from item]') propclass = self.properties[property] value = self.cl.get(self.nodeid, property) if isinstance(propclass, hyperdb.Multilink): return str(len(value)) - return '[Count: not a Multilink]' + return _('[Count: not a Multilink]') # XXX pretty is definitely new ;) def do_reldate(self, property, pretty=0): @@ -322,10 +324,10 @@ class TemplateFunctions: with the 'pretty' flag, make it pretty ''' if not self.nodeid and self.form is None: - return '[Reldate: not called from item]' + return _('[Reldate: not called from item]') propclass = self.properties[property] if isinstance(not propclass, hyperdb.Date): - return '[Reldate: not a Date]' + return _('[Reldate: not a Date]') if self.nodeid: value = self.cl.get(self.nodeid, property) else: @@ -333,7 +335,7 @@ class TemplateFunctions: interval = value - date.Date('.') if pretty: if not self.nodeid: - return 'now' + return _('now') pretty = interval.pretty() if pretty is None: pretty = value.pretty() @@ -345,7 +347,7 @@ class TemplateFunctions: allow you to download files ''' if not self.nodeid: - return '[Download: not called from item]' + return _('[Download: not called from item]') propclass = self.properties[property] value = self.cl.get(self.nodeid, property) if isinstance(propclass, hyperdb.Link): @@ -359,7 +361,7 @@ class TemplateFunctions: linkvalue = linkcl.get(value, k) l.append('%s'%(linkcl, value, linkvalue)) return ', '.join(l) - return '[Download: not a link]' + return _('[Download: not a link]') def do_checklist(self, property, **args): @@ -369,7 +371,7 @@ class TemplateFunctions: propclass = self.properties[property] if (not isinstance(propclass, hyperdb.Link) and not isinstance(propclass, hyperdb.Multilink)): - return '[Checklist: not a link]' + return _('[Checklist: not a link]') # get our current checkbox state if self.nodeid: @@ -404,8 +406,8 @@ class TemplateFunctions: checked = 'checked' else: checked = '' - l.append('[unselected]:'%(checked, property)) + l.append(_('[unselected]:')%(checked, property)) return '\n'.join(l) def do_note(self, rows=5, cols=80): @@ -423,7 +425,7 @@ class TemplateFunctions: ''' propcl = self.properties[property] if not isinstance(propcl, hyperdb.Multilink): - return '[List: not a Multilink]' + return _('[List: not a Multilink]') value = self.cl.get(self.nodeid, property) if reverse: value.reverse() @@ -445,14 +447,14 @@ class TemplateFunctions: ''' list the history of the item ''' if self.nodeid is None: - return "[History: node doesn't exist]" + return _("[History: node doesn't exist]") l = ['', '', - '', - '', - '', - ''] + _(''), + _(''), + _(''), + _('')] for id, date, user, action, args in self.cl.history(self.nodeid): l.append(''%( @@ -465,11 +467,11 @@ class TemplateFunctions: ''' add a submit button for the item ''' if self.nodeid: - return '' + return _('') elif self.form is not None: - return '' + return _('') else: - return '[Submit: not called from item]' + return _('[Submit: not called from item]') # @@ -589,7 +591,7 @@ class IndexTemplate(TemplateFunctions): for nodeid in nodeids: # check for a group heading if group_names: - this_group = [self.cl.get(nodeid, name, '[no value]') for name in group_names] + this_group = [self.cl.get(nodeid, name, _('[no value]')) for name in group_names] if this_group != old_group: l = [] for name in group_names: @@ -599,7 +601,8 @@ class IndexTemplate(TemplateFunctions): key = group_cl.getkey() value = self.cl.get(nodeid, name) if value is None: - l.append('[unselected %s]'%prop.classname) + l.append(_('[unselected %(classname)s]')%{ + 'classname': prop.classname}) else: l.append(group_cl.get(self.cl.get(nodeid, name), key)) @@ -609,9 +612,9 @@ class IndexTemplate(TemplateFunctions): for value in self.cl.get(nodeid, name): l.append(group_cl.get(value, key)) else: - value = self.cl.get(nodeid, name, '[no value]') + value = self.cl.get(nodeid, name, _('[no value]')) if value is None: - value = '[empty %s]'%name + value = _('[empty %(name)s]')%locals() else: value = str(value) l.append(value) @@ -654,12 +657,12 @@ class IndexTemplate(TemplateFunctions): # display the filter section w('
DateUserActionArgsDateUserActionArgs
%s%s%s%s
') w('') - w(' ') + w(_(' ')) w('') replace = IndexTemplateReplace(self.globals, locals(), filter) w(replace.go(template)) w('') - w('') + w(_('')) w('
Filter specification...Filter specification...
 
') # now add in the filter/columns/group/etc config table form @@ -685,9 +688,9 @@ class IndexTemplate(TemplateFunctions): w('' % name) # TODO: The widget style can go into the stylesheet - w('' + w(_('' ' View ' - 'customisation...\n'%(len(names)+1, action)) + 'customisation...\n')%(len(names)+1, action)) if not show_customization: w('\n') @@ -700,8 +703,7 @@ class IndexTemplate(TemplateFunctions): # Filter if all_filters: - w('' - 'Filters\n') + w(_('Filters\n')) for name in names: if name not in all_filters: w(' ') @@ -715,8 +717,7 @@ class IndexTemplate(TemplateFunctions): # Columns if all_columns: - w('' - 'Columns\n') + w(_('Columns\n')) for name in names: if name not in all_columns: w(' ') @@ -729,8 +730,7 @@ class IndexTemplate(TemplateFunctions): w('\n') # Grouping - w('' - 'Grouping\n') + w(_('Grouping\n')) for name in names: prop = self.properties[name] if name not in all_columns: @@ -745,7 +745,7 @@ class IndexTemplate(TemplateFunctions): w(' ') w(''%len(names)) - w('') + w(_('')) w('\n') w('\n') @@ -885,6 +885,14 @@ class NewItemTemplate(TemplateFunctions): # # $Log: not supported by cvs2svn $ +# Revision 1.49 2001/12/20 15:43:01 rochecompaan +# Features added: +# . Multilink properties are now displayed as comma separated values in +# a textbox +# . The add user link is now only visible to the admin user +# . Modified the mail gateway to reject submissions from unknown +# addresses if ANONYMOUS_ACCESS is denied +# # Revision 1.48 2001/12/20 06:13:24 rochecompaan # Bugs fixed: # . Exception handling in hyperdb for strings-that-look-like numbers got -- 2.30.2