[Zope3-checkins] CVS: Zope3/src/zope/i18n - translate.py:1.9.12.1

Sidnei da Silva sidnei at x3ng.com.br
Fri Feb 27 12:57:58 EST 2004


Update of /cvs-repository/Zope3/src/zope/i18n
In directory cvs.zope.org:/tmp/cvs-serv2876

Modified Files:
      Tag: runyaga-sip-branch
	translate.py 
Log Message:
Temporary fix, while Stephan Richter figures out the Real Fix (tm).


=== Zope3/src/zope/i18n/translate.py 1.9 => 1.9.12.1 ===
--- Zope3/src/zope/i18n/translate.py:1.9	Thu Feb  5 17:52:21 2004
+++ Zope3/src/zope/i18n/translate.py	Fri Feb 27 12:57:57 2004
@@ -38,34 +38,16 @@
         self._context = context
         self._translation_service = getService(context, 'Translation')
 
-    def translate(self, msgid, mapping=None, default=None):
+    def translate(self, msgid, mapping=None, context=None, default=None):
         """Translate the source msgid using the given mapping.
 
         See ITranslationService for details.
         """
-        # XXX Note that we cannot pass `context` to translation service as it
-        #     is most likely a Zope container that is not adaptable to
-        #     IUserPreferredLanguages.  It would be possible to pass the
-        #     request if we had it (ZopeContext, which is currently the only
-        #     user of Translator, has the request and could pass it to us
-        #     here).
-        #
-        #     OTOH if the request had information about user's preferred
-        #     languages, self._locale.id.language would most likely be not
-        #     None.  Therefore passing request is only useful in one case:
-        #     when the user asked for an exotic language for which we have no
-        #     locale, and there were no fallback languages with a supported
-        #     locale.
-        #
-        #     Note that this also uncovers an interesting situation.  Suppose
-        #     the user sets HTTP_ACCEPT_LANGUAGES to lg, en;q=0.5.
-        #     BrowserRequest looks for a locale matching 'lg', does not find
-        #     it and settles on a locale for 'en'.  When we get here,
-        #     self._locale.id.language is 'en', so 'lg' translations will not
-        #     be used even if available.  Perhaps the fix would be to only
-        #     specify context=self.request and just ignore
-        #     self._locale.id.language.
+        # XXX Temporary fix while Stephan Richter provides
+        # provides a better one. Ignore locale, and pass context
+        # instead, which should be the request or an object
+        # that can be adapted to IUserPreferredLangs.
         return self._translation_service.translate(
             msgid, self._domain, mapping=mapping,
-            target_language=self._locale.id.language,
+            context=context,
             default=default)




More information about the Zope3-Checkins mailing list