From f0c3b33c7d6d8afc3cd6fa4dda8199eca3c6c22f Mon Sep 17 00:00:00 2001 From: richard Date: Sat, 5 Jan 2002 02:22:32 +0000 Subject: [PATCH] i18n'ification git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@497 57a73879-2fb5-44c3-a270-3262357dd7e2 --- cgi-bin/roundup.cgi | 21 +++++++++++++-------- roundup-mailgw | 21 +++++++++++++-------- roundup-server | 39 +++++++++++++++++++++------------------ roundup/cgitb.py | 15 ++++++++++----- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/cgi-bin/roundup.cgi b/cgi-bin/roundup.cgi index f1d5518..93c1ebd 100755 --- a/cgi-bin/roundup.cgi +++ b/cgi-bin/roundup.cgi @@ -16,10 +16,11 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup.cgi,v 1.22 2001-12-13 00:20:01 richard Exp $ +# $Id: roundup.cgi,v 1.23 2002-01-05 02:19:03 richard Exp $ # python version check from roundup import version_check +from roundup.i18n import _ # ## Configuration @@ -68,7 +69,7 @@ try: from roundup import cgitb except: print "Content-Type: text/html\n" - print "Failed to import cgitb.
"
+    print _("Failed to import cgitb.
")
     s = StringIO.StringIO()
     traceback.print_exc(None, s)
     print cgi.escape(s.getvalue()), "
" @@ -161,15 +162,15 @@ def main(out, err): request.send_header('Content-Type', 'text/html') request.end_headers() w = request.write - w('Roundup instances index\n') - w('

Roundup instances index

    \n') + w(_('Roundup instances index\n')) + w(_('

    Roundup instances index

      \n')) homes = ROUNDUP_INSTANCE_HOMES.keys() homes.sort() for instance in homes: - w('
    1. %s\n'%( - os.environ['SCRIPT_NAME'], urllib.quote(instance), - cgi.escape(instance))) - w('
    ') + w(_('
  1. %(instance_name)s\n')%{ + 'instance_url': os.environ['SCRIPT_NAME']+'/'+urllib.quote(instance), + 'instance_name': cgi.escape(instance)}) + w(_('
')) # # Now do the actual CGI handling @@ -196,6 +197,10 @@ LOG.close() # # $Log: not supported by cvs2svn $ +# Revision 1.22 2001/12/13 00:20:01 richard +# . Centralised the python version check code, bumped version to 2.1.1 (really +# needs to be 2.1.2, but that isn't released yet :) +# # Revision 1.21 2001/12/02 05:06:16 richard # . We now use weakrefs in the Classes to keep the database reference, so # the close() method on the database is no longer needed. diff --git a/roundup-mailgw b/roundup-mailgw index 1e1f4b4..00905c0 100755 --- a/roundup-mailgw +++ b/roundup-mailgw @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-mailgw,v 1.18 2001-12-13 00:20:01 richard Exp $ +# $Id: roundup-mailgw,v 1.19 2002-01-05 02:19:03 richard Exp $ # python version check from roundup import version_check @@ -24,6 +24,7 @@ from roundup import version_check import sys, os, re, cStringIO from roundup.mailgw import Message +from roundup.i18n import _ def do_pipe(handler): '''Read a message from standard input and pass it to the mail handler. @@ -64,7 +65,7 @@ def do_pop(handler, server, user='', password=''): ''' import getpass, poplib if not user: - user = raw_input('User: ') + user = raw_input(_('User: ')) if not password: password = getpass.getpass() @@ -92,8 +93,8 @@ def do_pop(handler, server, user='', password=''): def usage(args, message=None): if message is not None: print message - print 'Usage: %s [source spec]'%args[0] - print ''' + print _('Usage: %(program)s [source spec]')%{'program': args[0]} + print _(''' The roundup mail gateway may be called in one of two ways: . with an instance home as the only argument, . with both an instance home and a mail spool file, or @@ -120,7 +121,7 @@ POP: pop server are both valid. The username and/or password will be prompted for if not supplied on the command-line. -''' +''') return 1 def main(args): @@ -148,7 +149,7 @@ def main(args): # otherwise, figure what sort of mail source to handle if len(args) < 4: - return usage(args, 'Error: not enough source specification information') + return usage(args, _('Error: not enough source specification information')) source, specification = args[2:] if source == 'mailbox': return do_mailbox(handler, specification) @@ -158,9 +159,9 @@ def main(args): if m: return do_pop(handler, m.group('server'), m.group('user'), m.group('pass')) - return usage(args, 'Error: pop specification not valid') + return usage(args, _('Error: pop specification not valid')) - return usage(args, 'Error: The source must be either "mailbox" or "pop"') + return usage(args, _('Error: The source must be either "mailbox" or "pop"')) # call main if __name__ == '__main__': @@ -168,6 +169,10 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.18 2001/12/13 00:20:01 richard +# . Centralised the python version check code, bumped version to 2.1.1 (really +# needs to be 2.1.2, but that isn't released yet :) +# # Revision 1.17 2001/12/02 05:06:16 richard # . We now use weakrefs in the Classes to keep the database reference, so # the close() method on the database is no longer needed. diff --git a/roundup-server b/roundup-server index 1d204e0..d7432d1 100755 --- a/roundup-server +++ b/roundup-server @@ -18,10 +18,7 @@ # """ HTTP Server that serves roundup. -Based on CGIHTTPServer in the Python library. - -$Id: roundup-server,v 1.23 2001-12-15 23:47:07 richard Exp $ - +$Id: roundup-server,v 1.24 2002-01-05 02:19:03 richard Exp $ """ # python version check @@ -33,6 +30,7 @@ import BaseHTTPServer # Roundup modules of use here from roundup import cgitb, cgi_client import roundup.instance +from roundup.i18n import _ # ## Configuration @@ -103,12 +101,13 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): self.send_header('Content-Type', 'text/html') self.end_headers() w = self.wfile.write - w('Roundup instances index\n') - w('

Roundup instances index

    \n') + w(_('Roundup instances index\n')) + w(_('

    Roundup instances index

      \n')) for instance in self.ROUNDUP_INSTANCE_HOMES.keys(): - w('
    1. %s\n'%(urllib.quote(instance), - cgi.escape(instance))) - w('
    ') + w(_('
  1. %(instance_name)s\n')%{ + 'instance_url': urllib.quote(instance), + 'instance_name': cgi.escape(instance)}) + w(_('
')) def inner_run_cgi(self): ''' This is the inner part of the CGI handling @@ -167,8 +166,9 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): client.main() def usage(message=''): - if message: message = 'Error: %s\n\n'%message - print '''%sUsage: + if message: + message = _('Error: %(error)s\n\n')%{'error': message} + print _('''%(message)sUsage: roundup-server [-n hostname] [-p port] [name=instance home]* -n: sets the host name @@ -181,7 +181,7 @@ roundup-server [-n hostname] [-p port] [name=instance home]* "roundup-admin init". You may specify any number of these name=home pairs on the command-line. For convenience, you may edit the ROUNDUP_INSTANCE_HOMES variable in the roundup-server file instead. -'''%message +'''%locals() sys.exit(0) def main(): @@ -207,18 +207,18 @@ def main(): try: import pwd except ImportError: - raise ValueError, "Can't change users - no pwd module" + raise ValueError, _("Can't change users - no pwd module") try: uid = pwd.getpwnam(user)[2] except KeyError: - raise ValueError, "User %s doesn't exist"%user + raise ValueError, _("User %(user)s doesn't exist")%locals() os.setuid(uid) elif os.getuid() and user is not None: - print 'WARNING: ignoring "-u" argument, not root' + print _('WARNING: ignoring "-u" argument, not root') # People can remove this check if they're really determined if not os.getuid() and user is None: - raise ValueError, "Can't run as root!" + raise ValueError, _("Can't run as root!") # handle instance specs if args: @@ -227,7 +227,7 @@ def main(): try: name, home = arg.split('=') except ValueError: - raise ValueError, "Instances must be name=home" + raise ValueError, _("Instances must be name=home") d[name] = home RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d except SystemExit: @@ -240,7 +240,7 @@ def main(): sys.argv = sys.argv[:1] address = (hostname, port) httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler) - print 'Roundup server started on', address + print _('Roundup server started on %(address)s')%locals() httpd.serve_forever() if __name__ == '__main__': @@ -248,6 +248,9 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.23 2001/12/15 23:47:07 richard +# sys module went away... +# # Revision 1.22 2001/12/13 00:20:01 richard # . Centralised the python version check code, bumped version to 2.1.1 (really # needs to be 2.1.2, but that isn't released yet :) diff --git a/roundup/cgitb.py b/roundup/cgitb.py index cc9217b..de017e4 100644 --- a/roundup/cgitb.py +++ b/roundup/cgitb.py @@ -1,7 +1,7 @@ # # This module was written by Ka-Ping Yee, . # -# $Id: cgitb.py,v 1.7 2001-11-22 15:46:42 jhermann Exp $ +# $Id: cgitb.py,v 1.8 2002-01-05 02:22:32 richard Exp $ __doc__ = """ Extended CGI traceback handler by Ka-Ping Yee, . @@ -9,6 +9,8 @@ Extended CGI traceback handler by Ka-Ping Yee, . import sys, os, types, string, keyword, linecache, tokenize, inspect, pydoc +from roundup.i18n import _ + def breaker(): return ('' + ' > ' + @@ -23,10 +25,10 @@ def html(context=5): '%s: %s'%(str(etype), str(evalue)), '#ffffff', '#aa55cc', pyver) - head = head + ('

A problem occurred while running a Python script. ' + head = head + (_('

A problem occurred while running a Python script. ' 'Here is the sequence of function calls leading up to ' 'the error, with the most recent (innermost) call first. ' - 'The exception attributes are:') + 'The exception attributes are:')) indent = '%s ' % (' ' * 5) traceback = [] @@ -73,13 +75,13 @@ def html(context=5): if locals.has_key(name): value = pydoc.html.repr(locals[name]) else: - value = 'undefined' + value = _('undefined') name = '%s' % name else: if frame.f_globals.has_key(name): value = pydoc.html.repr(frame.f_globals[name]) else: - value = 'undefined' + value = _('undefined') name = 'global %s' % name lvals.append('%s = %s' % (name, value)) if lvals: @@ -122,6 +124,9 @@ def handler(): # # $Log: not supported by cvs2svn $ +# Revision 1.7 2001/11/22 15:46:42 jhermann +# Added module docstrings to all modules. +# # Revision 1.6 2001/09/29 13:27:00 richard # CGI interfaces now spit up a top-level index of all the instances they can # serve. -- 2.30.2