[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/preference/ Preferences title and description are made translatable

Dmitry Vasiliev dima at hlabs.spb.ru
Fri Jul 8 07:22:15 EDT 2005


Log message for revision 31028:
  Preferences title and description are made translatable
  

Changed:
  U   Zope3/trunk/src/zope/app/preference/browser.py
  UU  Zope3/trunk/src/zope/app/preference/interfaces.py
  _U  Zope3/trunk/src/zope/app/preference/preference.py

-=-
Modified: Zope3/trunk/src/zope/app/preference/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/browser.py	2005-07-08 11:05:33 UTC (rev 31027)
+++ Zope3/trunk/src/zope/app/preference/browser.py	2005-07-08 11:22:14 UTC (rev 31028)
@@ -16,10 +16,12 @@
 $Id: menu.py 29269 2005-02-23 22:22:48Z srichter $
 """
 __docformat__ = 'restructuredtext'
+
 import re
 import zope.interface
 import zope.schema
 from zope.security.proxy import removeSecurityProxy
+from zope.i18n import translate
 
 from zope.app import zapi
 from zope.app.basicskin.standardmacros import StandardMacros
@@ -28,9 +30,11 @@
 from zope.app.pagetemplate.simpleviewclass import simple
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.app.tree.browser.cookie import CookieTreeView
+from zope.app.i18n import ZopeMessageIDFactory as _
 
 from zope.app.preference import interfaces
 
+
 NoneInterface = zope.interface.interface.InterfaceClass('None')
 
 class PreferencesMacros(StandardMacros):
@@ -53,8 +57,8 @@
                 return True
 
         return False
-        
 
+
 class PreferencesTree(CookieTreeView):
     """Preferences Tree using the stateful cookie tree."""
 
@@ -63,6 +67,7 @@
         filter = PreferenceGroupFilter()
         return self.cookieTree(root, filter)
 
+pref_msg = _("${name} Preferences")
 
 class EditPreferenceGroup(EditView):
 
@@ -74,13 +79,16 @@
             self.schema = NoneInterface 
             zope.interface.alsoProvides(removeSecurityProxy(context),
                                         NoneInterface)
-            
-        self.label = context.__title__ + ' Preferences'
+
+        self.label = pref_msg
+        self.label.mapping["name"] = translate(context.__title__,
+            context=request, default=context.__title__)
         super(EditPreferenceGroup, self).__init__(context, request)
         self.setPrefix(context.__id__)
 
     def getIntroduction(self):
         text = self.context.__description__ or self.schema.__doc__
+        text = translate(text, context=self.request, default=text)
 
         # Determine common whitespace ...
         cols = len(re.match('^[ ]*', text).group())
@@ -94,4 +102,3 @@
         source = zapi.createObject('zope.source.rest', text)
         renderer = zapi.getMultiAdapter((source, self.request))
         return renderer.render()
-

Modified: Zope3/trunk/src/zope/app/preference/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/interfaces.py	2005-07-08 11:05:33 UTC (rev 31027)
+++ Zope3/trunk/src/zope/app/preference/interfaces.py	2005-07-08 11:22:14 UTC (rev 31028)
@@ -19,6 +19,7 @@
 
 import zope.interface
 import zope.schema
+from zope.configuration.fields import MessageID
 
 from zope.app.container.interfaces import IReadContainer
 from zope.app.location.interfaces import ILocation
@@ -50,12 +51,12 @@
         description=u"Schema describing the preferences of the group.",
         required=False)
 
-    __title__ = zope.schema.TextLine(
+    __title__ = MessageID(
         title=u"Title",
         description=u"The title of the group used in the UI.",
         required=True)
 
-    __description__ = zope.schema.Text(
+    __description__ = MessageID(
         title=u"Description",
         description=u"The description of the group used in the UI.",
         required=False)


Property changes on: Zope3/trunk/src/zope/app/preference/interfaces.py
___________________________________________________________________
Name: svn:keywords
   + Id


Property changes on: Zope3/trunk/src/zope/app/preference/preference.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Zope3-Checkins mailing list