From 79d9e36a0b824548a0f2bc83cb948fc5ce668151 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 24 Nov 2009 20:43:11 -0500 Subject: Do not create the .mo files during setup. This makes things go much faster. The tests do require a partial French translation for digester.txt, so just include the bare minimum, already msgfmt'd in the mailman.testing package. --- src/mailman/testing/i18n.py | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/mailman/testing/i18n.py (limited to 'src/mailman/testing/i18n.py') 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 . + +"""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) -- cgit v1.2.3-70-g09d2