diff options
| -rw-r--r-- | setup.py | 24 | ||||
| -rw-r--r-- | src/mailman/__init__.py | 14 | ||||
| -rw-r--r-- | src/mailman/core/i18n.py | 15 | ||||
| -rw-r--r-- | src/mailman/testing/i18n.py | 56 | ||||
| -rw-r--r-- | src/mailman/testing/mailman-fr.mo | bin | 0 -> 1945 bytes | |||
| -rw-r--r-- | src/mailman/testing/mailman-fr.po | 84 |
6 files changed, 175 insertions, 18 deletions
@@ -49,18 +49,18 @@ with open('src/mailman/version.py') as fp: # Create the .mo files from the .po files. There may be errors and warnings # here and that could cause the digester.txt test to fail. -start_dir = os.path.dirname('src/mailman/messages') -for dirpath, dirnames, filenames in os.walk(start_dir): - for filename in filenames: - po_file = os.path.join(dirpath, filename) - basename, ext = os.path.splitext(po_file) - if ext <> '.po': - continue - mo_file = basename + '.mo' - if (not os.path.exists(mo_file) or - os.path.getmtime(po_file) > os.path.getmtime(mo_file)): - # The mo file doesn't exist or is older than the po file. - os.system('msgfmt -o %s %s' % (mo_file, po_file)) +## start_dir = os.path.dirname('src/mailman/messages') +## for dirpath, dirnames, filenames in os.walk(start_dir): +## for filename in filenames: +## po_file = os.path.join(dirpath, filename) +## basename, ext = os.path.splitext(po_file) +## if ext <> '.po': +## continue +## mo_file = basename + '.mo' +## if (not os.path.exists(mo_file) or +## os.path.getmtime(po_file) > os.path.getmtime(mo_file)): +## # The mo file doesn't exist or is older than the po file. +## os.system('msgfmt -o %s %s' % (mo_file, po_file)) diff --git a/src/mailman/__init__.py b/src/mailman/__init__.py index 5f1ced22f..21645b4fb 100644 --- a/src/mailman/__init__.py +++ b/src/mailman/__init__.py @@ -24,6 +24,10 @@ __all__ = [ ] +import os +import sys + + # lazr.restful uses the sha module, but that's deprecated in Python 2.6 in # favor of the hashlib module. import warnings @@ -40,6 +44,12 @@ except ImportError: __path__ = pkgutil.extend_path(__path__, __name__) -# We have to initialize the i18n subsystem before anything else happens. -from mailman.core.i18n import initialize +# We have to initialize the i18n subsystem before anything else happens, +# however, we'll initialize it differently for tests. We have to do it this +# early so that module contents is set up before anything that needs it is +# imported. +if sys.argv[0].split(os.sep)[-1] == 'test': + from mailman.testing.i18n import initialize +else: + from mailman.core.i18n import initialize initialize() diff --git a/src/mailman/core/i18n.py b/src/mailman/core/i18n.py index 8083fd987..6a9482b80 100644 --- a/src/mailman/core/i18n.py +++ b/src/mailman/core/i18n.py @@ -38,11 +38,18 @@ _ = None -def initialize(): - """Initialize the i18n subsystem.""" +def initialize(application=None): + """Initialize the i18n subsystem. + + :param application: An optional `flufl.i18n.Application` instance to use + as the translation context. This primarily exists to support the + testing environment. + :type application: `flufl.i18n.Application` + """ global _ - strategy = PackageStrategy('mailman', mailman.messages) - application = registry.register(strategy) + if application is None: + strategy = PackageStrategy('mailman', mailman.messages) + application = registry.register(strategy) _ = application._ diff --git a/src/mailman/testing/i18n.py b/src/mailman/testing/i18n.py new file mode 100644 index 000000000..63ad878c6 --- /dev/null +++ b/src/mailman/testing/i18n.py @@ -0,0 +1,56 @@ +# Copyright (C) 2009 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. + +"""Internationalization for the tests.""" + +from __future__ import absolute_import, unicode_literals + +__metaclass__ = type +__all__ = [ + 'install_testing_i18n', + ] + + +from contextlib import closing +from flufl.i18n import registry +from gettext import GNUTranslations, NullTranslations +from pkg_resources import resource_stream + +from mailman.core.i18n import initialize as core_initialize + + + +class TestingStrategy: + """A strategy that finds catalogs in the testing directory.""" + + def __init__(self, name): + self.name = name + + def __call__(self, language_code): + if language_code == 'en': + return NullTranslations() + mo_file = 'mailman-%s.mo' % language_code + with closing(resource_stream('mailman.testing', mo_file)) as fp: + return GNUTranslations(fp) + + + +def initialize(): + """Install a global underscore function for testing purposes.""" + strategy = TestingStrategy('mailman-testing') + application = registry.register(strategy) + core_initialize(application) diff --git a/src/mailman/testing/mailman-fr.mo b/src/mailman/testing/mailman-fr.mo Binary files differnew file mode 100644 index 000000000..df721cb0f --- /dev/null +++ b/src/mailman/testing/mailman-fr.mo diff --git a/src/mailman/testing/mailman-fr.po b/src/mailman/testing/mailman-fr.po new file mode 100644 index 000000000..5f8c910e2 --- /dev/null +++ b/src/mailman/testing/mailman-fr.po @@ -0,0 +1,84 @@ +# Catalogues Mailman en Français. +# Copyright (C) 2001, 2006 Free Software Foundation, Inc. +# Ousmane Wilane <wilane@cyg.sn>, 2002. +# Pascal George <george@lyon.inserm.fr>, 2003-2005. +# Frederic Daniel Luc Lehobey, 2006. +msgid "" +msgstr "" +"Project-Id-Version: mailman\n" +"POT-Creation-Date: Sun Jan 8 15:53:47 2006\n" +"PO-Revision-Date: 2006-11-14 12:07+0100\n" +"Last-Translator: Frederic Daniel Luc Lehobey\n" +"Language-Team: mailman-fr <mailman-fr@rezo.net>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.3\n" + +#: templates/en/masthead.txt:1 +msgid "" +"Send $real_name mailing list submissions to\n" +"\t$got_list_email\n" +"\n" +"To subscribe or unsubscribe via the World Wide Web, visit\n" +"\t$got_listinfo_url\n" +"or, via email, send a message with subject or body 'help' to\n" +"\t$got_request_email\n" +"\n" +"You can reach the person managing the list at\n" +"\t$got_owner_email\n" +"\n" +"When replying, please edit your Subject line so it is more specific than\n" +"\"Re: Contents of $real_name digest...\"" +msgstr "" +"Envoyez vos messages pour la liste $real_name à\n" +"\t$got_list_email\n" +"\n" +"Pour vous (dés)abonner par le web, consultez\n" +"\t$got_listinfo_url\n" +"\n" +"ou, par courriel, envoyez un message avec « help » dans le corps\n" +"ou dans le sujet à\n" +"\t$got_request_email\n" +"\n" +"Vous pouvez contacter l'administrateur de la liste à l'adresse\n" +"\t$got_owner_email\n" +"\n" +"Si vous répondez, n'oubliez pas de changer l'objet du message afin\n" +"qu'il soit plus spécifique que « Re: Contenu du groupe de $real_name... »" + +#: Mailman/Handlers/ToDigest.py:159 +msgid "$realname Digest, Vol $volume, Issue $issue" +msgstr "Groupe $realname, Vol. $volume, Parution $issue" + +#: Mailman/Handlers/ToDigest.py:205 +msgid "digest header" +msgstr "en-tête des remises groupées" + +#: Mailman/Handlers/ToDigest.py:208 +msgid "Digest Header" +msgstr "En-tête des remises groupées" + +#: Mailman/Handlers/ToDigest.py:221 +msgid "Today's Topics:\n" +msgstr "Thèmes du jour :\n" + +#: Mailman/Handlers/ToDigest.py:301 +msgid "Today's Topics (%(msgcount)d messages)" +msgstr "Thèmes du jour (%(msgcount)d messages)" + +#: Mailman/Handlers/ToDigest.py:327 +msgid "[Message discarded by content filter]" +msgstr "[Message rejeté par filtrage de contenu]" + +#: Mailman/Handlers/ToDigest.py:359 +msgid "digest footer" +msgstr "pied de page des remises groupées" + +#: Mailman/Handlers/ToDigest.py:362 +msgid "Digest Footer" +msgstr "Pied de page des remises groupées" + +#: Mailman/Handlers/ToDigest.py:376 +msgid "End of " +msgstr "Fin de " |
