[Zope3-checkins] SVN: Zope3/trunk/ local INegotiator support:
Roger Ineichen
roger at projekt01.ch
Mon Nov 15 20:13:32 EST 2004
Log message for revision 28455:
local INegotiator support:
Changed negotiator import with "INegotiator" utility lookup in default global
"TranslationDomain". This makes it possible to use local INegotiator
utilities in the standard translation domain.
Fixed browser widget translate test (added INegotiator adapter).
Added CHANGES.txt comment.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/zope/app/form/browser/tests/test_browserwidget.py
U Zope3/trunk/src/zope/i18n/translationdomain.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2004-11-15 10:59:19 UTC (rev 28454)
+++ Zope3/trunk/doc/CHANGES.txt 2004-11-16 01:13:32 UTC (rev 28455)
@@ -192,6 +192,11 @@
Bug Fixes
+ - Changed negotiator import with "INegotiator" utility lookup in
+ default global "TranslationDomain". This makes it possible to
+ use local INegotiator utilities with the standard translation
+ domain.
+
- contents.html no longer breaks when no IAdding is available.
- Fixed the page that reports "system errors", errors that
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_browserwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_browserwidget.py 2004-11-15 10:59:19 UTC (rev 28454)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_browserwidget.py 2004-11-16 01:13:32 UTC (rev 28455)
@@ -26,6 +26,8 @@
from zope.app.form.interfaces import WidgetInputError, MissingInputError
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.i18n.interfaces import ITranslationDomain
+from zope.i18n.interfaces import INegotiator
+from zope.i18n.negotiator import negotiator
from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
from zope.i18n.translationdomain import TranslationDomain
from zope.publisher.browser import TestRequest
@@ -110,6 +112,7 @@
domain = TranslationDomain('zope')
domain.addCatalog(catalog)
ztapi.provideUtility(ITranslationDomain, domain, 'zope')
+ ztapi.provideUtility(INegotiator, negotiator)
self.assertEqual(self._widget.label, 'oofay itletay')
Modified: Zope3/trunk/src/zope/i18n/translationdomain.py
===================================================================
--- Zope3/trunk/src/zope/i18n/translationdomain.py 2004-11-15 10:59:19 UTC (rev 28454)
+++ Zope3/trunk/src/zope/i18n/translationdomain.py 2004-11-16 01:13:32 UTC (rev 28455)
@@ -15,12 +15,12 @@
$Id$
"""
-from zope.i18n.negotiator import negotiator
from zope.i18n.simpletranslationdomain import SimpleTranslationDomain
from zope.i18n.messageid import MessageID
from zope.i18n import interpolate
from zope.component import getUtility
from zope.i18n.interfaces import ITranslationDomain
+from zope.i18n.interfaces import INegotiator
# The configuration should specify a list of fallback languages for the
# site. If a particular catalog for a negotiated language is not available,
@@ -72,11 +72,12 @@
return u''
if target_language is None and context is not None:
- # Try to determine target language from context
langs = self._catalogs.keys()
+ # invoke local or global unnamed 'INegotiator' utilities
+ negotiator = getUtility(INegotiator)
+ # try to determine target language from negotiator utility
target_language = negotiator.getLanguage(langs, context)
-
# MessageID attributes override arguments
if isinstance(msgid, MessageID):
if msgid.domain != self.domain:
More information about the Zope3-Checkins
mailing list