language: added full translation support
[treecutter.git] / treecutter / sitemap.py
index 11e300eda9fbc0ff0d8ac6c4e718dfdb27e576dc..74b01cfbfe1be02344899b8ed1b8caf33d21dc42 100644 (file)
@@ -12,7 +12,8 @@ from time import time
 from treecutter import constants as const
 from treecutter.trie import Trie
 from treecutter.link import Link
-from treecutter.tools import ssh_cmd, publish, mkdir_p
+from treecutter.tools import ssh_cmd, publish, mkdir_p,get_folder_size,sizeof_fmt
+
 
 class Sitemap():
     """Class keeping the internal site structure"""
@@ -56,11 +57,13 @@ class Sitemap():
     def set(self):
         return set(link.link() for link in self._tree)
 
+    def linklist(self):
+        return [link.link() for link in self._tree]
+
     # Main driver in the application processing the documents
     # in the collected sitemap
     def process(self):
         t1 = time()
-        print "Prepareing the input"
         for link in self._tree:
             link.prepare()
         t2 = time()
@@ -117,17 +120,19 @@ class Sitemap():
             isoxml = u"//iso_639_3_entry[@*='"+l+"']"
             ln = self._isocode.xpath(isoxml)[0].get('name')
             if lang != 'en':
-                ln = self._tranlang[lang].gettext(ln)
+                ln = self._tranlang[lang].ugettext(ln)
             p = unicode(link.link())
             if p[-1] == u'/':
                 p = p +u'index'
             p = p+u'.'+l
-            li = html.li(html.a(ln.decode('utf-8'),
+            li = html.li(html.a(ln,
                                 href=self._subdir+p,hreflang=l))
             menu.append(li)
-        return etree.tostring(menu,encoding='UTF-8',pretty_print=False)
+#            print type(etree.tostring(menu,encoding='unicode',pretty_print=False))
+        return etree.tostring(menu,encoding='unicode',pretty_print=False)
 
     def publish(self):
+        print "Size [ %7s ]" % (sizeof_fmt(get_folder_size(self._tmptarget)))
         ssh_cmd(self._output,"mkdir -p")
         publish(self._tmptarget, self._output)
         for res in ["stylesheets","images","js","fonts","favicon.ico"]: