[Checkins] SVN: Zope3/trunk/src/zope/app/component/browser/ Added translatable messages

Dmitry Vasiliev dima at hlabs.spb.ru
Tue May 2 06:52:27 EDT 2006


Log message for revision 67828:
  Added translatable messages
  

Changed:
  U   Zope3/trunk/src/zope/app/component/browser/registration.pt
  U   Zope3/trunk/src/zope/app/component/browser/registration.py
  U   Zope3/trunk/src/zope/app/component/browser/registration.txt
  U   Zope3/trunk/src/zope/app/component/browser/siteregistration.pt

-=-
Modified: Zope3/trunk/src/zope/app/component/browser/registration.pt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/registration.pt	2006-05-02 10:31:31 UTC (rev 67827)
+++ Zope3/trunk/src/zope/app/component/browser/registration.pt	2006-05-02 10:52:25 UTC (rev 67828)
@@ -2,13 +2,13 @@
     i18n:domain="zope">
 <body>
 <div metal:fill-slot="body">
-<form tal:attributes="action request/URL" 
+<form tal:attributes="action request/URL"
       method="POST"
       >
 
   <div tal:condition="not:view/registrations">
     <p i18n:translate="">
-      This object isn't yet registered.  Click 
+      This object isn't yet registered.  Click
       <a href="@@addRegistration.html">here</a>
       to register the object.
     </p>
@@ -20,16 +20,23 @@
     <table>
       <tr tal:repeat="registration view/registrations">
          <td>
-           <input type="checkbox" 
+           <input type="checkbox"
                   class="noborder" name="ids:list"
                   tal:attributes="value registration/id;
                                   id registration/id;
                                   "
                   />
          </td>
-         <td tal:content="structure registration/render">
-           zope.app.fooIFoo utility named bob
-           comment: needed a bob
+         <td tal:define="info registration/render">
+           <tal:block content="info/info">
+             zope.app.fooIFoo utility named bob
+           </tal:block>
+           <tal:block condition="info/comment">
+             <br />
+             <tal:block content="info/comment">
+               comment: needed a bob
+             </tal:block>
+           </tal:block>
          </td>
       </tr>
       <tr>
@@ -40,7 +47,7 @@
         </td>
       </tr>
     </table>
-    <p>
+    <p i18n:translate="">
       Click <a href="@@addRegistration.html">here</a>
       to register the object again.
     </p>

Modified: Zope3/trunk/src/zope/app/component/browser/registration.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/registration.py	2006-05-02 10:31:31 UTC (rev 67827)
+++ Zope3/trunk/src/zope/app/component/browser/registration.py	2006-05-02 10:52:25 UTC (rev 67828)
@@ -29,6 +29,7 @@
 from zope.app import zapi
 from zope.app.i18n import ZopeMessageFactory as _
 
+
 def _registrations(context, comp):
     sm = component.getSiteManager(context)
     for r in sm.registeredUtilities():
@@ -61,7 +62,7 @@
 class ISiteRegistrationDisplay(IRegistrationDisplay):
     """Display registration information, including the component registered
     """
-            
+
 class RegistrationView(BrowserPage):
 
     component.adapts(None, zope.publisher.interfaces.browser.IBrowserRequest)
@@ -113,24 +114,33 @@
     def _comment(self):
         comment = self.context.info or ''
         if comment:
-            comment = '<br />comment: ' + comment
+            comment = _("comment: ${comment}", mapping={"comment": comment})
         return comment
 
-    def render(self):
+    def _provided(self):
         name = self.context.name
-        return "%s utility%s%s" % (
-            self.provided(),
-            name and (' named ' + name) or '',
-            self._comment(),
-            )
+        provided = self.provided()
+        if name:
+            info = _("${provided} utility named '${name}'",
+                     mapping={"provided": provided, "name": name})
+        else:
+            info = _("${provided} utility",
+                     mapping={"provided": provided})
+        return info
 
+    def render(self):
+        return {
+            "info": self._provided(),
+            "comment": self._comment()
+            }
+
     def unregister(self):
         self.context.registry.unregisterUtility(
             self.context.component,
             self.context.provided,
             self.context.name,
             )
-            
+
 class SiteRegistrationView(RegistrationView):
 
     render = zope.app.pagetemplate.ViewPageTemplateFile('siteregistration.pt')
@@ -154,27 +164,20 @@
         try:
             url = url()
         except TypeError:
-            url = None
+            url = ""
 
-        cname = getattr(self.context.component, '__name__', '(unknown name)')
-        if cname is None:
-            cname = ''
+        cname = getattr(self.context.component, '__name__', '')
+        if not cname:
+            cname = _("(unknown name)")
         if url:
-            cname = '<a href="%s/@@SelectedManagementView.html">%s</a>' % (
-                url, cname)
-        else:
-            cname = '%s (moved or deleted)' % cname
+            url += "/@@SelectedManagementView.html"
 
-        name = self.context.name
-        comment = self.context.info
-        
-        return ('%s<br />%s utility%s%s'
-                % (cname,
-                   self.provided(),
-                   name and (' named ' + name) or '',
-                   self._comment(),
-                   )
-                )
+        return {
+            "cname": cname,
+            "url": url,
+            "info": self._provided(),
+            "comment": self._comment()
+            }
 
 class AddUtilityRegistration(form.Form):
     """View for registering utilities
@@ -186,7 +189,7 @@
 
     A subclass can provide a 'provided' attribute if a component
     should always be registered with the same interface.
-    
+
     """
     component.adapts(None, zope.publisher.interfaces.browser.IBrowserRequest)
 
@@ -251,17 +254,16 @@
         provided = self.provided
         if provided is None:
             provided = data['provided']
-            
-        
+
         # We have to remove the security proxy to save the registration
         sm.registerUtility(
             removeSecurityProxy(self.context),
             provided, name,
             data['comment'] or '')
-        
+
         if 'UPDATE_SUBMIT' in self.request.form:
             # Backward compat until 3.5
             self.request.response.redirect('@@SelectedManagementView.html')
             return
-        
+
         self.request.response.redirect('@@registration.html')

Modified: Zope3/trunk/src/zope/app/component/browser/registration.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/registration.txt	2006-05-02 10:31:31 UTC (rev 67827)
+++ Zope3/trunk/src/zope/app/component/browser/registration.txt	2006-05-02 10:52:25 UTC (rev 67828)
@@ -75,8 +75,9 @@
 
     >>> print browser.contents
     <!DOCTYPE html ...
-    ...zope.app.component.browser.tests.ISample
-    utility<br />comment: unnamed sample...
+    ...[[zope][zope.app.component.browser.tests.ISample utility]]
+    <br />
+    [[zope][comment: unnamed sample]]...
 
 We can create multiple registrations by selecting "here" again:
 
@@ -86,10 +87,10 @@
 
     >>> print browser.contents
     <!DOCTYPE html ...
-    ...zope.app.component.browser.tests.ISample
-    utility<br />comment: unnamed sample...
-    ...zope.app.component.browser.tests.ISample
-    utility named one...
+    ...[[zope][zope.app.component.browser.tests.ISample utility]]
+    <br />
+    [[zope][comment: unnamed sample]]...
+    ...[[zope][zope.app.component.browser.tests.ISample utility named 'one']]...
 
 Each entry has a checkbox for selecting it.  This can be used to
 unregister an object. We'll unregister the utility named "one":
@@ -98,7 +99,7 @@
     ... value='Rem9wZS5hcHAuY29tcG9uZW50LmJyb3dzZXIudGVzdHMuSVNhbXBsZSBvbmU'
     ... ).selected = True
     >>> browser.getControl('[[zope][unregister-button (Unregister)]]').click()
-    >>> 'utility named one' not in browser.contents
+    >>> "utility named 'one'" not in browser.contents
     True
 
 If there is already an object registered, new registrations will
@@ -122,10 +123,11 @@
     ...[[zope][Registrations for this site: (
     Registrations for this site:
     )]]...
-    ...sample1...zope.app.component.browser.tests.ISample
-    utility<br />comment: unnamed sample...
-    ...sample2...zope.app.component.browser.tests.ISample
-    utility named two...
+    ...sample1...[[zope][zope.app.component.browser.tests.ISample utility]]
+    <br />
+    [[zope][comment: unnamed sample]]...
+    ...sample2...[[zope][zope.app.component.browser.tests.ISample
+    utility named 'two']]...
 
 This shows all of the registrations for the site, including our sample
 registrations. The display includes a link to each component.  Now,
@@ -145,10 +147,11 @@
     ...[[zope][Registrations for this site: (
     Registrations for this site:
     )]]...
-    ...sample1...zope.app.component.browser.tests.ISample
-    utility<br />comment: unnamed sample...
-    ...sample3...zope.app.component.browser.tests.ISample
-    utility named two...
+    ...sample1...[[zope][zope.app.component.browser.tests.ISample utility]]
+    <br />
+    [[zope][comment: unnamed sample]]...
+    ...sample3...[[zope][zope.app.component.browser.tests.ISample
+    utility named 'two']]...
 
     >>> 'sample2' not in browser.contents
     True
@@ -189,8 +192,14 @@
     ...[[zope][Registrations for this site: (
     Registrations for this site:
     )]]...
-    ...(moved or deleted)...zope.app.component.browser.tests.ISample
-    utility<br />comment: unnamed sample...
+    ...[[zope][[[zope][(unknown name)]] (moved or deleted) (
+    [[zope][(unknown name)]]
+    (moved or deleted)
+    )]]
+    <br />
+    [[zope][zope.app.component.browser.tests.ISample utility]]
+    <br />
+    [[zope][comment: unnamed sample]]...
 
     >>> browser.getControl(name='ids:list').getControl(
     ... value="Rem9wZS5hcHAuY29tcG9uZW50LmJyb3dzZXIudGVzdHMuSVNhbXBsZSA"

Modified: Zope3/trunk/src/zope/app/component/browser/siteregistration.pt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/siteregistration.pt	2006-05-02 10:31:31 UTC (rev 67827)
+++ Zope3/trunk/src/zope/app/component/browser/siteregistration.pt	2006-05-02 10:52:25 UTC (rev 67828)
@@ -2,7 +2,7 @@
     i18n:domain="zope">
 <body>
 <div metal:fill-slot="body">
-<form tal:attributes="action request/URL" 
+<form tal:attributes="action request/URL"
       method="POST"
       >
   <div tal:condition="not:view/registrations">
@@ -15,17 +15,35 @@
     <table>
       <tr tal:repeat="registration view/registrations">
          <td>
-           <input type="checkbox" 
+           <input type="checkbox"
                   class="noborder" name="ids:list"
                   tal:attributes="value registration/id;
                                   id registration/id;
                                   "
                   />
          </td>
-         <td tal:content="structure registration/render">
-           <a href="foo/bar">foo/bar</a><br />
-           zope.app.fooIFoo utility named bob
-           comment: needed a bob
+         <td tal:define="info registration/render">
+           <tal:block condition="info/url">
+             <a href="foo/bar" tal:attributes="href info/url"
+               tal:content="info/cname">foo/bar</a>
+           </tal:block>
+           <tal:block condition="not: info/url"
+             i18n:translate="">
+             <tal:block i18n:name="name" content="info/cname">
+               foo/bar
+             </tal:block>
+             (moved or deleted)
+           </tal:block>
+           <br />
+           <tal:block content="info/info">
+             zope.app.fooIFoo utility named bob
+           </tal:block>
+           <tal:block condition="info/comment">
+             <br />
+             <tal:block content="info/comment">
+               comment: needed a bob
+             </tal:block>
+           </tal:block>
          </td>
       </tr>
       <tr>



More information about the Checkins mailing list