[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Internationalized apidoc modules description.

Dmitry Vasiliev dima at hlabs.spb.ru
Thu Sep 2 03:59:07 EDT 2004


Log message for revision 27410:
  Internationalized apidoc modules description.
  
  Not sure about removeSecurityProxy() call inside the _translate()
  method, but otherwise some of the apidoc functional tests has been broken.
  Needs someone review.
  


Changed:
  U   Zope3/trunk/src/zope/app/apidoc/browser/apidoc.py
  U   Zope3/trunk/src/zope/app/apidoc/classmodule/__init__.py
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/__init__.py
  U   Zope3/trunk/src/zope/app/apidoc/servicemodule/__init__.py
  U   Zope3/trunk/src/zope/app/apidoc/utilitymodule/__init__.py
  U   Zope3/trunk/src/zope/app/apidoc/viewmodule/__init__.py
  U   Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py
  U   Zope3/trunk/src/zope/i18n/__init__.py


-=-
Modified: Zope3/trunk/src/zope/app/apidoc/browser/apidoc.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/apidoc.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/app/apidoc/browser/apidoc.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -17,6 +17,7 @@
 """
 __docformat__ = 'restructuredtext'
 
+from zope.i18n import translate
 from zope.app.apidoc.utilities import renderText
 
 class APIDocumentationView(object):
@@ -28,8 +29,10 @@
         Example::
 
           >>> from zope.app.apidoc import APIDocumentation
+          >>> from zope.publisher.browser import TestRequest
           
           >>> view = APIDocumentationView()
+          >>> view.request = TestRequest()
           >>> view.context = APIDocumentation(None, '++apidoc++')
           >>> info = view.getModuleList()
           >>> info = [(i['name'], i['title']) for i in info]
@@ -38,8 +41,14 @@
         """
         items = list(self.context.items())
         items.sort()
-        return [{'name': name,
-                 'title': module.title,
-                 'description': renderText(module.description,
-                                           module.__class__.__module__)}
-                for name, module in items ]
+        result = []
+        for name, module in items:
+            description = translate(module.description, context=self.request,
+                                    default=module.description)
+            description = renderText(description, module.__class__.__module__)
+            if not isinstance(description, unicode):
+                description = unicode(description, "utf-8")
+            result.append({'name': name,
+                           'title': module.title,
+                           'description': description})
+        return result

Modified: Zope3/trunk/src/zope/app/apidoc/classmodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/classmodule/__init__.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/app/apidoc/classmodule/__init__.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -567,7 +567,7 @@
     title = _('Classes')
 
     # See zope.app.apidoc.interfaces.IDocumentationModule
-    description = """
+    description = _("""
     This module allows you to get an overview of the modules and classes
     defined in the Zope 3 framework and its supporting packages. There are
     two methods to navigate through the modules to find the classes you are
@@ -587,7 +587,7 @@
     implemented interfaces, attributes and methods, but it also lists the
     interface that requires a method or attribute to be implemented and the
     permissions required to access it.
-    """
+    """)
     rootModules = ['ZConfig', 'ZODB', 'transaction', 'zdaemon', 'zope']
 
     def __init__(self):

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/__init__.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/__init__.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -75,7 +75,7 @@
     title = _('Interfaces')
 
     # See zope.app.apidoc.interfaces.IDocumentationModule
-    description = """
+    description = _("""
     All used and important interfaces are registered through the interface
     service. While it would be possible to just list all attributes, it is
     hard on the user to read such an overfull list. Therefore, interfaces that
@@ -85,7 +85,7 @@
     information, including of course the declared attributes/fields and
     methods, but also available adapters, services and utilities that provide
     this interface.
-    """
+    """)
 
     def get(self, key, default=None):
         """See zope.app.interfaces.container.IReadContainer"""

Modified: Zope3/trunk/src/zope/app/apidoc/servicemodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/servicemodule/__init__.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/app/apidoc/servicemodule/__init__.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -75,23 +75,24 @@
     title = _('Services')
 
     # See zope.app.apidoc.interfaces.IDocumentationModule
-    description = """
+    description = _("""
     The services module let's the reader browse through all defined
     services. It uses the service name as a key. In general services can be
     queried using::
 
       >>> from zope.app import zapi
-      >>> service = zapi.getGlobalService('ServiceName')
+      >>> service = zapi.getService('ServiceName')
 
-    Here we used 'None' as the location, which means that always a global
-    service is returned. If you use an object that has a location in the
-    traversal tree, you will generally get the closest service, which includes
-    the local ones. The second argument is the service name, which you can
-    replace with any name listed in this module's menu.
+    Here we used 'None' as the context by default, which means that
+    always a global service is returned. If you use an object that has
+    a location in the traversal tree, you will generally get the closest
+    service, which includes the local ones. The first argument is the
+    service name, which you can replace with any name listed in this
+    module's menu.
 
     For each service, the attributes and methods of the service interface are
     presented. At the end a list of implementations is given.
-    """
+    """)
 
     def get(self, key, default=None):
         """See zope.app.container.interfaces.IReadContainer"""

Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/__init__.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/__init__.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -129,7 +129,7 @@
     title = _('Utilities')
 
     # See zope.app.apidoc.interfaces.IDocumentationModule
-    description = """
+    description = _("""
     Utilities are also nicely registered in a service, so that it is easy to
     create a listing of available utilities. A utility is identified by the
     providing interface and a name, which can be empty. The menu provides you
@@ -138,7 +138,7 @@
 
     Again, the documentation of a utility lists all the attributes/fields and
     methods the utility provides and provides a link to the implementation. 
-    """
+    """)
 
     def get(self, key, default=None):
         parts = key.split('.')

Modified: Zope3/trunk/src/zope/app/apidoc/viewmodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/viewmodule/__init__.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/app/apidoc/viewmodule/__init__.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -65,7 +65,7 @@
     title = _('Presentations')
 
     # See zope.app.apidoc.interfaces.IDocumentationModule
-    description = """
+    description = _("""
     The Presentations (or Views) module is somewhat crazy, since a view or
     resource cannot be identified by a single interface or name, but of four
     to five pieces of information. Conclusively, the menu lets you select an
@@ -87,7 +87,7 @@
     Completely independent of all this, there is a link "Show Skins, Layers
     and Usages" that brings you to a simple screen that shows the mapping of
     the layers to skins and provides a list of available usages.
-    """
+    """)
 
     def getSkins(self):
         """Get the names of all available skins.

Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -192,7 +192,7 @@
     title = _('ZCML Reference')
 
     # See zope.app.apidoc.interfaces.IDocumentationModule
-    description = """
+    description = _("""
     This module presents you with a complete list of ZCML directives and
     serves therefore well as reference. The menu provides you with a tree that
     organizes the directives by namespaces.
@@ -203,7 +203,7 @@
     file the directive was declared in. At the end a list of available
     subdirectives is given, also listing the implemented interface and
     available attributes.
-    """
+    """)
 
     def _makeDocStructure(self):
         # Some trivial caching

Modified: Zope3/trunk/src/zope/i18n/__init__.py
===================================================================
--- Zope3/trunk/src/zope/i18n/__init__.py	2004-09-02 07:05:38 UTC (rev 27409)
+++ Zope3/trunk/src/zope/i18n/__init__.py	2004-09-02 07:59:06 UTC (rev 27410)
@@ -17,6 +17,7 @@
 """
 import re
 import warnings
+from zope.security.proxy import isinstance, removeSecurityProxy
 from zope.component import queryUtility
 from zope.i18nmessageid import MessageIDFactory, MessageID
 from zope.i18n.interfaces import ITranslationDomain
@@ -33,6 +34,7 @@
 def _translate(msgid, domain=None, mapping=None, context=None,
                target_language=None, default=None):
 
+    msgid = removeSecurityProxy(msgid)
 
     if isinstance(msgid, MessageID):
         domain = msgid.domain



More information about the Zope3-Checkins mailing list