[Zope3-checkins] CVS: Zope3/src/zope/i18n/tests - en-alt.mo:1.2 en-alt.po:1.2 test_globaltranslationservice.py:1.7 test_itranslationservice.py:1.3
Jim Fulton
jim@zope.com
Fri, 28 Mar 2003 19:06:26 -0500
Update of /cvs-repository/Zope3/src/zope/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv20015/src/zope/i18n/tests
Modified Files:
en-alt.mo en-alt.po test_globaltranslationservice.py
test_itranslationservice.py
Log Message:
Fixed bugs in global translation service:
- Returned message id on failed serach when no message catalogs
were found. Should have returned None.
- Failed lookups with multiple catalogs unless all catalogs had a
translation.
Fixed bug in local translation services:
- Returned message id on failed serach
Added a default argument to translate. This allows the default
text, which could be the message id, to be passed.
=== Zope3/src/zope/i18n/tests/en-alt.mo 1.1 => 1.2 ===
<Binary-ish file>
=== Zope3/src/zope/i18n/tests/en-alt.po 1.1 => 1.2 ===
--- Zope3/src/zope/i18n/tests/en-alt.po:1.1 Tue Mar 25 12:01:53 2003
+++ Zope3/src/zope/i18n/tests/en-alt.po Fri Mar 28 19:06:26 2003
@@ -10,3 +10,5 @@
msgid "short_greeting"
msgstr "Hey!"
+msgid "special"
+msgstr "Wow"
=== Zope3/src/zope/i18n/tests/test_globaltranslationservice.py 1.6 => 1.7 ===
--- Zope3/src/zope/i18n/tests/test_globaltranslationservice.py:1.6 Tue Mar 25 19:19:58 2003
+++ Zope3/src/zope/i18n/tests/test_globaltranslationservice.py Fri Mar 28 19:06:26 2003
@@ -54,13 +54,21 @@
self._service.setLanguageFallbacks([])
# Test that we have at least the minimum required arguments
raises(TypeError, translate, 'Hello')
+
# Test that a translation in an unsupported language returns the
- # original message id unchanged, if there is no fallback language
+ # default, if there is no fallback language
eq(translate('default', 'short_greeting', target_language='es'),
+ None)
+ eq(translate('default', 'short_greeting',
+ target_language='es', default='short_greeting'),
'short_greeting')
+
# Same test, but use the context argument instead of target_language
context = Environment()
eq(translate('default', 'short_greeting', context=context),
+ None)
+ eq(translate('default', 'short_greeting', context=context,
+ default='short_greeting'),
'short_greeting')
# Test that at least one of context or target_language is given
raises(TypeError, translate, 'short_greeting', context=None)
@@ -71,6 +79,16 @@
self.assertEqual(translate('default', u'short_greeting',
target_language='en'),
u'Hello!')
+
+ def testStringTranslate_w_MultipleCatalogs(self):
+ path = testdir()
+ self._service.addCatalog(
+ GettextMessageCatalog('en', 'alt',
+ os.path.join(path, 'en-default.mo')))
+ translate = self._service.translate
+ self.assertEqual(translate('alt', u'special',
+ target_language='en'),
+ u'Wow')
def testMessageIDTranslate(self):
translate = self._service.translate
=== Zope3/src/zope/i18n/tests/test_itranslationservice.py 1.2 => 1.3 ===
--- Zope3/src/zope/i18n/tests/test_itranslationservice.py:1.2 Tue Mar 25 19:19:58 2003
+++ Zope3/src/zope/i18n/tests/test_itranslationservice.py Fri Mar 28 19:06:26 2003
@@ -89,6 +89,17 @@
eq(translate('default', 'short_greeting', context=context),
'Hallo!')
+
+ def testSimpleTranslate_bad_domain(self):
+ translate = self._service.translate
+ eq = self.assertEqual
+ eq(translate('defaultnot', 'short_greeting', target_language='de'),
+ None)
+ eq(translate('defaultnot', 'short_greeting', target_language='de',
+ default=42),
+ 42)
+
+
def testDynamicTranslate(self):
translate = self._service.translate
eq = self.assertEqual