############################################################################## # # Copyright (c) 2004, 2005 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Unit tests for the i18n framework $Id: test_i18n.py 68331 2006-05-29 09:47:23Z philikon $ """ import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) def test_zpt_i18n(): """ Test i18n functionality in ZPTs >>> configure_zcml = ''' ... ... ... ... ... ... ... ... ''' >>> import Products.Five >>> from Products.Five import zcml >>> zcml.load_config("configure.zcml", Products.Five) >>> zcml.load_string(configure_zcml) In order to be able to traverse to the PageTemplate view, we need a traversable object: >>> from Products.Five.tests.testing import manage_addFiveTraversableFolder >>> manage_addFiveTraversableFolder(self.folder, 'testoid', 'Testoid') We tell Zope to translate the messages by passing the ``Accept-Language`` header which is processed by the ``IUserPreferredLangauges`` adapter: >>> print http(r''' ... GET /test_folder_1_/testoid/@@i18n.html HTTP/1.1 ... Accept-Language: de ... ''') HTTP/1.1 200 OK ...

Dies ist eine Nachricht

Dies ist eine explizite Nachricht

Dies sind 4 Nachrichten

Dies sind 4 explizite Nachrichten

Dies ist eine Nachricht

Dies ist eine Nachricht

... Clean up: >>> from zope.app.testing.placelesssetup import tearDown >>> tearDown() """ def test_suite(): from Testing.ZopeTestCase import FunctionalDocTestSuite from zope.testing.doctest import ELLIPSIS return FunctionalDocTestSuite(optionflags=ELLIPSIS) if __name__ == '__main__': framework()