[Zope3-checkins] CVS: Zope3/src/zope/app/services/translation - translationservice.py:1.8
Marius Gedminas
mgedmin@codeworks.lt
Fri, 11 Apr 2003 09:20:43 -0400
Update of /cvs-repository/Zope3/src/zope/app/services/translation
In directory cvs.zope.org:/tmp/cvs-serv29011/src/zope/app/services/translation
Modified Files:
translationservice.py
Log Message:
Changed ITranslationService to not require context when target_language is not
specified. Rationale: if language negotiation fails, target_language will
still be None, and we have to cope with that anyway.
Added a unit test and updated the three ITranslationService implementations.
=== Zope3/src/zope/app/services/translation/translationservice.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/services/translation/translationservice.py:1.7 Fri Mar 28 19:06:24 2003
+++ Zope3/src/zope/app/services/translation/translationservice.py Fri Apr 11 09:20:12 2003
@@ -77,14 +77,11 @@
if domain is None:
domain = self.default_domain
- if target_language is None:
- if context is None:
- raise TypeError, 'No destination language'
- else:
- avail_langs = self.getAvailableLanguages(domain)
- # Let's negotiate the language to translate to. :)
- negotiator = getService(self, 'LanguageNegotiation')
- target_language = negotiator.getLanguage(avail_langs, context)
+ if target_language is None and context is not None:
+ avail_langs = self.getAvailableLanguages(domain)
+ # Let's negotiate the language to translate to. :)
+ negotiator = getService(self, 'LanguageNegotiation')
+ target_language = negotiator.getLanguage(avail_langs, context)
# Get the translation. Default is the source text itself.
catalog_names = self._catalogs.get((target_language, domain), [])