opental-checkins
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OpenTAL-checkins] opental/PlacelessTranslationService GettextMess...


From: Fernando Lalo Martins
Subject: [OpenTAL-checkins] opental/PlacelessTranslationService GettextMess...
Date: Fri, 28 Feb 2003 06:08:09 -0500

CVSROOT:        /cvsroot/opental
Module name:    opental
Changes by:     Fernando Lalo Martins <address@hidden>  03/02/28 06:08:06

Modified files:
        PlacelessTranslationService: GettextMessageCatalog.py 
                                     PlacelessTranslationService.py 
        PlacelessTranslationService/www: catalog_info.pt catalog_test.pt 

Log message:
        porting the UI to ZPT (optionally)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/PlacelessTranslationService/GettextMessageCatalog.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/PlacelessTranslationService/PlacelessTranslationService.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/PlacelessTranslationService/www/catalog_info.pt.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/PlacelessTranslationService/www/catalog_test.pt.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: opental/PlacelessTranslationService/GettextMessageCatalog.py
diff -u opental/PlacelessTranslationService/GettextMessageCatalog.py:1.7 
opental/PlacelessTranslationService/GettextMessageCatalog.py:1.8
--- opental/PlacelessTranslationService/GettextMessageCatalog.py:1.7    Thu Feb 
27 20:53:14 2003
+++ opental/PlacelessTranslationService/GettextMessageCatalog.py        Fri Feb 
28 06:08:04 2003
@@ -17,12 +17,11 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
 """A simple implementation of a Message Catalog. 
 
-$Id: GettextMessageCatalog.py,v 1.7 2003/02/28 01:53:14 lalo Exp $
+$Id: GettextMessageCatalog.py,v 1.8 2003/02/28 11:08:04 lalo Exp $
 """
 
 from gettext import GNUTranslations
-import os
-import codecs
+import os, types, codecs
 from types import DictType, StringType, UnicodeType
 from OFS.Traversable import Traversable
 from Persistence import Persistent
@@ -33,8 +32,16 @@
 try:
     from Products.OpenPT.OpenPTFile import OpenPTFile as ptFile
 except ImportError:
-    #FIXME: ZPT
-    ptFile = None
+    from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+    from Globals import package_home
+    def ptFile(id, *filename):
+        if type(filename[0]) is types.DictType:
+            filename = list(filename)
+            filename[0] = package_home(filename[0])
+        filename = os.path.join(*filename)
+        if not os.path.splitext(filename)[1]:
+            filename = filename + '.pt'
+        return PageTemplateFile(filename, '', __name__=id)
 
 # template to use to write missing entries to .missing
 missing_template = u"""msgid "%(id)s"
@@ -56,6 +63,7 @@
     meta_type = title = 'Gettext Message Catalog'
     icon = 'misc_/PlacelessTranslationService/GettextMessageCatalog.png'
     __roles__=('Manager',)
+    title__roles__=__roles__
 
     def __init__(self, path_to_file):
         """Initialize the message catalog"""
@@ -166,6 +174,10 @@
         """
         return self.__translation_object._info.get(name, None)
 
+    Title__roles__ = __roles__
+    def Title(self):
+        return self.title
+
     ############################################################
     # Zope/OFS integration
     
@@ -182,6 +194,7 @@
 
     zmi_test = ptFile('zmi_test', globals(), 'www', 'catalog_test')
 
+    file_exists__roles__ = __roles__
     def file_exists(self):
         try:
             file = open(self._path_to_file, 'rb')
@@ -189,6 +202,7 @@
             return False
         return True
 
+    displayInfo__roles__ = __roles__
     def displayInfo(self):
         self._prepareTranslations()
         info = self.__translation_object._info
Index: opental/PlacelessTranslationService/PlacelessTranslationService.py
diff -u opental/PlacelessTranslationService/PlacelessTranslationService.py:1.13 
opental/PlacelessTranslationService/PlacelessTranslationService.py:1.14
--- opental/PlacelessTranslationService/PlacelessTranslationService.py:1.13     
Thu Feb 27 20:37:43 2003
+++ opental/PlacelessTranslationService/PlacelessTranslationService.py  Fri Feb 
28 06:08:04 2003
@@ -17,10 +17,10 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
 """Placeless Translation Service for providing I18n to file-based code.
 
-$Id: PlacelessTranslationService.py,v 1.13 2003/02/28 01:37:43 lalo Exp $
+$Id: PlacelessTranslationService.py,v 1.14 2003/02/28 11:08:04 lalo Exp $
 """
 
-import re, zLOG, Globals
+import sys, re, zLOG, Globals
 from OFS.Folder import Folder
 from types import DictType, StringType, UnicodeType
 from Negotiator import negotiator
@@ -33,6 +33,10 @@
         return str(v)
 
 def log(msg, severity=zLOG.INFO, detail='', error=None):
+    if type(msg) is UnicodeType:
+        msg = msg.encode(sys.getdefaultencoding(), 'replace')
+    if type(detail) is UnicodeType:
+        detail = detail.encode(sys.getdefaultencoding(), 'replace')
     zLOG.LOG('PlacelessTranslationService', severity, msg, detail, error)
 
 def map_get(map, name):
Index: opental/PlacelessTranslationService/www/catalog_info.pt
diff -u opental/PlacelessTranslationService/www/catalog_info.pt:1.1 
opental/PlacelessTranslationService/www/catalog_info.pt:1.2
--- opental/PlacelessTranslationService/www/catalog_info.pt:1.1 Thu Feb 27 
20:41:06 2003
+++ opental/PlacelessTranslationService/www/catalog_info.pt     Fri Feb 28 
06:08:06 2003
@@ -1,8 +1,8 @@
-<h1 tal:replace="structure context/manage_page_header">Header</h1>
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
 <h2 tal:define="manage_tabs_message options/manage_tabs_message | nothing"
-    tal:replace="structure context/manage_tabs">Tabs</h2>
+    tal:replace="structure here/manage_tabs">Tabs</h2>
 
-<h1 tal:content="here/title">Gettext message catalog</h1>
+<h1 tal:content="here/Title">Gettext message catalog</h1>
 
 <table cellspacing="2">
 <tr tal:repeat="info here/displayInfo">
@@ -21,4 +21,4 @@
 </h3>
 </tal:block>
 
-<h1 tal:replace="structure context/manage_page_footer">Footer</h1>
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
Index: opental/PlacelessTranslationService/www/catalog_test.pt
diff -u opental/PlacelessTranslationService/www/catalog_test.pt:1.1 
opental/PlacelessTranslationService/www/catalog_test.pt:1.2
--- opental/PlacelessTranslationService/www/catalog_test.pt:1.1 Thu Feb 27 
20:41:06 2003
+++ opental/PlacelessTranslationService/www/catalog_test.pt     Fri Feb 28 
06:08:06 2003
@@ -1,8 +1,8 @@
-<h1 tal:replace="structure context/manage_page_header">Header</h1>
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
 <h2 tal:define="manage_tabs_message options/manage_tabs_message | nothing"
-    tal:replace="structure context/manage_tabs">Tabs</h2>
+    tal:replace="structure here/manage_tabs">Tabs</h2>
 
-<h1>Test <tal:block content="here/title">this message catalog</tal:block></h1>
+<h1>Test <tal:block content="here/Title">this message catalog</tal:block></h1>
 
 <div tal:condition="request/msgid | nothing">
 
@@ -39,4 +39,4 @@
 <input type="submit" value="Translate this phrase" />
 </form>
 
-<h1 tal:replace="structure context/manage_page_footer">Footer</h1>
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]