[Cdd-commits] r831 - in cdd/trunk/webtools: . templates

CDD Subversion Commit noreply at alioth.debian.org
Wed Jun 18 09:36:46 UTC 2008


Author: tille
Date: Wed Jun 18 09:36:46 2008
New Revision: 831

Modified:
   cdd/trunk/webtools/cddtasktools.py
   cdd/trunk/webtools/tasks.py
   cdd/trunk/webtools/templates/tasks.xhtml
Log:
DDTP translation WOULD work if there would not be these strange Unicode problems: genshi.Markup tries unicode(description) and fails - I have no idea why because the descriptions are properly UTF-8 encoded. :-(


Modified: cdd/trunk/webtools/cddtasktools.py
==============================================================================
--- cdd/trunk/webtools/cddtasktools.py	(original)
+++ cdd/trunk/webtools/cddtasktools.py	Wed Jun 18 09:36:46 2008
@@ -99,15 +99,15 @@
         LongDesc += "</pre>\n"
     return (ShortDesc, LongDesc)
 
-def MarkupString(string, pkg, elem):
+def MarkupString(string, pkg, elem, lang='en'):
     # Genshi does not touch strings that are marked with "Markup()"
     # This function does the actual Markup call for any string with error checking
 
     try:
         string = Markup(string)
     except UnicodeDecodeError, errtxt:
-        print >> stderr, "%s UnicodeDecodeError in %s: '%s'; ErrTxt: %s" % \
-                                    (elem, pkg, string, errtxt)
+        print >> stderr, "----> %s UnicodeDecodeError in %s (lang='%s'): '%s'; ErrTxt: %s" % \
+                                    (elem, pkg, lang, string, errtxt)
         string = "DEBUG: Element %s of %s has Unicode problems" % (elem, pkg)
     return string
 
@@ -173,7 +173,13 @@
         self.tasks           = {}
         self.tasknames       = []
         self.available       = available
-        self.alldeps_in_main = []
+        self.alldeps_in_main = [] # sorted string list of package names with all packages
+                                  # relevant for a CDD that are in main Debian (for use in DDTP)
+        self.alldeps_in_main_info = {} # complete dictionary with package information
+                                  # with all packages relevant for a CDD that are in
+                                  # main to easily feed DDTP translation into the structures
+                                  # -->
+                                  # self.alldeps_in_main = self.alldeps_in_main_info.keys().sort()
 
     def GetTasknames(self):
         for task in os.listdir(self.tasksdir):
@@ -272,6 +278,7 @@
                     # add only packages in main, because others do not have DDTP translations
                     if tdep.component == 'main':
                         self.alldeps_in_main.append(tdep.pkg)
+                        self.alldeps_in_main_info[tdep.pkg] = tdep
         self.alldeps_in_main.sort()
         return self.alldeps_in_main
 
@@ -297,8 +304,9 @@
         component = 'main'
 
         pks2translate = self.GetAllDependantPackagesOfCDD()
-        trans = {}
         for lang in languages:
+            if lang == 'en':
+                continue
             # f = urllib.urlopen(DDTPURL+dist+'/'+component+DDTPDIR+'/'+lang)
             cachefile = cachedir+'/'+dist+'_'+component+'_'+lang+'.'+COMPRESSIONEXTENSION
             (file,info) = urllib.urlretrieve(DDTPURL+dist+'/'+component+DDTPDIR+lang+'.'+COMPRESSIONEXTENSION,cachefile)
@@ -310,13 +318,17 @@
                 print >>stderr, "Unknown compression extension " + COMPRESSIONEXTENSION
                 return exit(-1)
 
-            trans[lang] = {}
             for stanza in deb822.Sources.iter_paragraphs(g, shared_storage=False):
                 pkg = stanza['package']
                 if pkg not in pks2translate:
                     continue
-                trans[lang][pkg] = SplitDescription(stanza['description-'+lang])
-        return trans
+
+                self.alldeps_in_main_info[pkg].desc[lang] = {}
+                (short, long) = SplitDescription(stanza['description-'+lang])
+
+                # Markup strings to enable verbatim output of preformatted text
+                self.alldeps_in_main_info[pkg].desc[lang]['short'] = MarkupString(short, pkg, 'pkgShortDesc', lang)
+                self.alldeps_in_main_info[pkg].desc[lang]['long']  = MarkupString(long,  pkg, 'pkgLongDesc', lang)
 
     def MarkupPreformatedStringsCDD(self):
         # Genshi does not touch strings that are marked with "Markup()" - so just

Modified: cdd/trunk/webtools/tasks.py
==============================================================================
--- cdd/trunk/webtools/tasks.py	(original)
+++ cdd/trunk/webtools/tasks.py	Wed Jun 18 09:36:46 2008
@@ -19,11 +19,14 @@
 
 CDD='debian-med'
 
+languages = ('en', 'da', 'de', 'fr', 'it', 'pt')
+
 cdeps=CddDependencies(CDD)
 cdeps.GetAllDependencies()
 tasks        = cdeps.tasknames
 packages     = cdeps.GetNamesOnlyDict()
 task_details = cdeps.GetTaskDescDict()
+cdeps.GetTranslations(languages)
 cdeps.MarkupPreformatedStringsCDD()
 
 # Define directories used
@@ -34,7 +37,6 @@
 # Initialize i18n
 domain = 'cdd-webtools'
 gettext.install(domain)
-languages = ('en', 'da', 'de', 'fr', 'it', 'pt')
 l10nstring = {}
 for lang in languages:
 	l10nstring[lang] = gettext.translation(domain, locale_dir, languages=[lang], fallback = True)

Modified: cdd/trunk/webtools/templates/tasks.xhtml
==============================================================================
--- cdd/trunk/webtools/templates/tasks.xhtml	(original)
+++ cdd/trunk/webtools/templates/tasks.xhtml	Wed Jun 18 09:36:46 2008
@@ -4,7 +4,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="${lang}" lang="${lang}"
       xmlns:py="http://genshi.edgewall.org/">
 <head>
-<title>$projectname</title>
+<title>$projectname $task packages</title>
 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
 <link href="$css" type="text/css" rel="stylesheet"/>
 </head>
@@ -57,7 +57,11 @@
 	     <a name="${project.pkg}" id="${project.pkg}"/>
 	     <strong>${project.pkg.capitalize()}</strong>
              <span py:if="project.wnpp != None"> - <a href="http://bugs.debian.org/#${project.wnpp}">wnpp</a></span><br />
-	     <em>${project.desc['en']['short']}</em><br/>
+	     <em><span py:choose="">
+	           <span py:when="project.desc.has_key(lang)">${project.desc[lang]['short']}</span>
+	           <span py:otherwise="">${project.desc['en']['short']}</span>
+	         </span>
+	     </em><br/>
 	     <a href="$project.homepage}">${project.homepage}</a>
 	     <div py:if="project.responsible != None"><span py:choose="type"><span py:when="'official'">${maintainer}</span><span py:otherwise="">${responsible}</span></span>: ${project.responsible}</div>
 	   </td>
@@ -74,8 +78,10 @@
            </td>
          </tr>
          <tr>
-           <td colspan="2" class="project-description">${project.desc['en']['long']}
-           </td>
+           <td colspan="2" class="project-description"><span py:choose="">
+	           <span py:when="project.desc.has_key(lang)">${project.desc[lang]['long']}</span>
+	           <span py:otherwise="">${project.desc['en']['long']}</span>
+	         </span></td>
          </tr>
        </tbody>
      </table>



More information about the Cdd-commits mailing list