[Zope3-checkins] CVS: Zope3/src/zope/i18n/tests - en-alt.mo:1.1 en-alt.po:1.1 test_globaltranslationservice.py:1.3
Paul Winkler
pw_lists@slinkp.com
Tue, 25 Mar 2003 12:01:54 -0500
Update of /cvs-repository/Zope3/src/zope/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv11211/src/zope/i18n/tests
Modified Files:
test_globaltranslationservice.py
Added Files:
en-alt.mo en-alt.po
Log Message:
Modified TranslationService to get the domain from msg id if possible.
=== Added File Zope3/src/zope/i18n/tests/en-alt.mo ===
<Binary-ish file>
=== Added File Zope3/src/zope/i18n/tests/en-alt.po ===
msgid ""
msgstr ""
"Project-Id-Version: Zope 3\n"
"PO-Revision-Date: 2002/06/13\n"
"Last-Translator: Zope 3 contributors\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "short_greeting"
msgstr "Hey!"
=== Zope3/src/zope/i18n/tests/test_globaltranslationservice.py 1.2 => 1.3 ===
--- Zope3/src/zope/i18n/tests/test_globaltranslationservice.py:1.2 Wed Dec 25 09:13:40 2002
+++ Zope3/src/zope/i18n/tests/test_globaltranslationservice.py Tue Mar 25 12:01:53 2003
@@ -18,8 +18,9 @@
import unittest, sys, os
from zope.i18n.globaltranslationservice import GlobalTranslationService
from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
-from zope.i18n.tests.test_ireadtranslationservice import TestIReadTranslationService, \
- Environment
+from zope.i18n.tests.test_ireadtranslationservice \
+ import TestIReadTranslationService, Environment
+from zope.i18n import MessageIDFactory
def testdir():
from zope.i18n import tests
@@ -35,6 +36,10 @@
os.path.join(path, 'en-default.mo'))
de_catalog = GettextMessageCatalog('de', 'default',
os.path.join(path, 'de-default.mo'))
+ alt_en_catalog = GettextMessageCatalog('en', 'alt',
+ os.path.join(path,
+ 'en-alt.mo'))
+ service.addCatalog(alt_en_catalog)
service.addCatalog(en_catalog)
service.addCatalog(de_catalog)
return service
@@ -58,6 +63,32 @@
# Test that at least one of context or target_language is given
raises(TypeError, translate, 'short_greeting', context=None)
+
+ def testStringTranslate(self):
+ translate = self._service.translate
+ self.assertEqual(translate('default', u'short_greeting',
+ target_language='en'),
+ u'Hello!')
+
+ def testMessageIDTranslate(self):
+ translate = self._service.translate
+ self.assertEqual(translate('default', u'short_greeting',
+ target_language='en'),
+ u'Hello!')
+ msgid = MessageIDFactory('alt')('short_greeting')
+ self.assertEqual(translate('default', msgid,
+ target_language='en'),
+ u'Hey!')
+
+ def testMessageIDTranslate_w_Domain(self):
+ translate = self._service.getDomain('default').translate
+ self.assertEqual(translate(u'short_greeting', target_language='en'),
+ u'Hello!')
+ msgid = MessageIDFactory('alt')('short_greeting')
+ self.assertEqual(translate(msgid, target_language='en'),
+ u'Hey!')
+
+
def testSimpleFallbackTranslation(self):
translate = self._service.translate
raises = self.assertRaises