diff options
author | Mark Sapiro <mark@msapiro.net> | 2016-02-27 15:21:12 -0800 |
---|---|---|
committer | Mark Sapiro <mark@msapiro.net> | 2016-02-27 15:21:12 -0800 |
commit | 95385417e926517c13ee769ef915ce5710a515f2 (patch) | |
tree | a39eccce0b844476a3715f328ee6712a5d62640e /Mailman | |
parent | 1833e1e51f4994d733c4ef3fca7c6ef7a4fd519e (diff) | |
parent | b3e0912e4d982e53eccac906fad347e8f1792b97 (diff) | |
download | mailman2-95385417e926517c13ee769ef915ce5710a515f2.tar.gz mailman2-95385417e926517c13ee769ef915ce5710a515f2.tar.xz mailman2-95385417e926517c13ee769ef915ce5710a515f2.zip |
Fixed l10n to use correct charset for command-line scripts.
Diffstat (limited to 'Mailman')
-rw-r--r-- | Mailman/MTA/Manual.py | 10 | ||||
-rw-r--r-- | Mailman/MTA/Postfix.py | 21 | ||||
-rw-r--r-- | Mailman/i18n.py | 29 |
3 files changed, 42 insertions, 18 deletions
diff --git a/Mailman/MTA/Manual.py b/Mailman/MTA/Manual.py index 92e1c03c..14158263 100644 --- a/Mailman/MTA/Manual.py +++ b/Mailman/MTA/Manual.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2005 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2016 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -25,7 +25,7 @@ from Mailman import mm_cfg from Mailman import Message from Mailman import Utils from Mailman.Queue.sbcache import get_switchboard -from Mailman.i18n import _ +from Mailman.i18n import _, C_ from Mailman.MTA.Utils import makealiases try: @@ -74,12 +74,12 @@ Here are the entries for the /etc/aliases file: outfp = sfp else: if not quiet: - print _("""\ + print C_("""\ To finish creating your mailing list, you must edit your /etc/aliases (or equivalent) file by adding the following lines, and possibly running the `newaliases' program: """) - print _("""\ + print C_("""\ ## %(listname)s mailing list""") outfp = sys.stdout # Common path @@ -120,7 +120,7 @@ Here are the entries in the /etc/aliases file that should be removed: """) outfp = sfp else: - print _(""" + print C_(""" To finish removing your mailing list, you must edit your /etc/aliases (or equivalent) file by removing the following lines, and possibly running the `newaliases' program: diff --git a/Mailman/MTA/Postfix.py b/Mailman/MTA/Postfix.py index 3f5c9984..8860459e 100644 --- a/Mailman/MTA/Postfix.py +++ b/Mailman/MTA/Postfix.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2014 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2016 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -27,7 +27,7 @@ from stat import * from Mailman import mm_cfg from Mailman import Utils from Mailman import LockFile -from Mailman.i18n import _ +from Mailman.i18n import C_ from Mailman.MTA.Utils import makealiases from Mailman.Logging.Syslog import syslog @@ -358,7 +358,7 @@ def checkperms(state): targetmode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP for file in ALIASFILE, VIRTFILE: if state.VERBOSE: - print _('checking permissions on %(file)s') + print C_('checking permissions on %(file)s') stat = None try: stat = os.stat(file) @@ -368,9 +368,9 @@ def checkperms(state): if stat and (stat[ST_MODE] & targetmode) <> targetmode: state.ERRORS += 1 octmode = oct(stat[ST_MODE]) - print _('%(file)s permissions must be 066x (got %(octmode)s)'), + print C_('%(file)s permissions must be 066x (got %(octmode)s)'), if state.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(file, stat[ST_MODE] | targetmode) else: print @@ -386,7 +386,7 @@ def checkperms(state): raise continue if state.VERBOSE: - print _('checking ownership of %(dbfile)s') + print C_('checking ownership of %(dbfile)s') user = mm_cfg.MAILMAN_USER ownerok = stat[ST_UID] == pwd.getpwnam(user)[2] if not ownerok: @@ -394,10 +394,11 @@ def checkperms(state): owner = pwd.getpwuid(stat[ST_UID])[0] except KeyError: owner = 'uid %d' % stat[ST_UID] - print _('%(dbfile)s owned by %(owner)s (must be owned by %(user)s'), + print C_( + '%(dbfile)s owned by %(owner)s (must be owned by %(user)s'), state.ERRORS += 1 if state.FIX: - print _('(fixing)') + print C_('(fixing)') uid = pwd.getpwnam(user)[2] gid = grp.getgrnam(mm_cfg.MAILMAN_GROUP)[2] os.chown(dbfile, uid, gid) @@ -406,9 +407,9 @@ def checkperms(state): if stat and (stat[ST_MODE] & targetmode) <> targetmode: state.ERRORS += 1 octmode = oct(stat[ST_MODE]) - print _('%(dbfile)s permissions must be 066x (got %(octmode)s)'), + print C_('%(dbfile)s permissions must be 066x (got %(octmode)s)'), if state.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(dbfile, stat[ST_MODE] | targetmode) else: print diff --git a/Mailman/i18n.py b/Mailman/i18n.py index 5f926b77..102bee83 100644 --- a/Mailman/i18n.py +++ b/Mailman/i18n.py @@ -1,4 +1,4 @@ -# Copyright (C) 2000-2010 by the Free Software Foundation, Inc. +# Copyright (C) 2000-2016 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,6 +17,7 @@ import sys import time +import locale import gettext from types import StringType, UnicodeType @@ -25,6 +26,15 @@ from Mailman.SafeDict import SafeDict _translation = None + +def _get_ctype_charset(): + old = locale.setlocale(locale.LC_CTYPE, '') + charset = locale.nl_langinfo(locale.CODESET) + locale.setlocale(locale.LC_CTYPE, old) + return charset + +_ctype_charset = _get_ctype_charset() + def set_language(language=None): @@ -54,7 +64,7 @@ if _translation is None: -def _(s): +def _(s, frame=1): if s == '': return s assert s @@ -70,7 +80,7 @@ def _(s): # original string is 1) locals dictionary, 2) globals dictionary. # # First, get the frame of the caller - frame = sys._getframe(1) + frame = sys._getframe(frame) # A `safe' dictionary is used so we won't get an exception if there's a # missing key in the dictionary. dict = SafeDict(frame.f_globals.copy()) @@ -95,6 +105,19 @@ def _(s): +def tolocale(s): + global _ctype_charset + if isinstance(s, UnicodeType): + return s + source = _translation.charset () + if not source: + return s + return unicode(s, source, 'replace').encode(_ctype_charset, 'replace') + +def C_(s): + return tolocale(_(s, 2)) + + def ctime(date): # Don't make these module globals since we have to do runtime translation # of the strings anyway. |