[wdoc] fallback to english title when no translation found stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 16 Feb 2011 08:54:09 +0100
branchstable
changeset 6996 86214f0da14f
parent 6993 656561eddd1d
child 7000 09e32d10e6bc
[wdoc] fallback to english title when no translation found
web/views/wdoc.py
--- a/web/views/wdoc.py	Tue Feb 15 23:30:01 2011 +0100
+++ b/web/views/wdoc.py	Wed Feb 16 08:54:09 2011 +0100
@@ -92,9 +92,14 @@
     return index
 
 def title_for_lang(node, lang):
+    fallback_title = None
     for title in node.findall('title'):
-        if title.attrib['{http://www.w3.org/XML/1998/namespace}lang'] == lang:
+        title_lang = title.attrib['{http://www.w3.org/XML/1998/namespace}lang']
+        if title_lang == lang:
             return unicode(title.text)
+        if title_lang == 'en':
+            fallback_title = unicode(title.text)
+    return fallback_title
 
 def subsections(node):
     return [child for child in node if child.tag == 'section']