]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - fixup-docbook-translated.rb
Make fixup-docbook-translated.rb a bit more verbose about what it is ignoring.
[text-madewithcc.git] / fixup-docbook-translated.rb
index 3f04247a60d9a4e660b6aee3cd64edbb4d0b89e3..d933346b03df41a1dbcb1bfc08da6d953a0f9219 100644 (file)
@@ -21,35 +21,39 @@ def log(level,what)
   end
 end
 
-log 0, 'Including the Spanish version introduction'
-if intro = File.open('extra/es/intro_es.xml', 'r').read rescue nil
+if intro = File.open('extra/%s/intro_%s.xml' % [lang, lang],
+                     'r').read rescue nil
+  log 0, 'Including the %s version introduction' % lang
   xml.search('preface').last.after( intro )
 else
-  log 0, ' -!- Introduction text not found or empty'
+  log 0, ' -!- Not including the %s introduction text' % lang
 end
 
-log 0, 'Final editorial requests: Attributions on top, as in other chapters, also for prefaces'
-xml.search('preface').each do |pref|
-  title = pref.search('title').first
-  attrib = pref.search('blockquote').last
-  attrib_text =  attrib.inner_text.gsub(/\s+/,' ')
+if 'es' == lang
+  log 0, 'Final editorial requests: Attributions on top, as in other chapters, also for prefaces'
+  xml.search('preface').each do |pref|
+    title = pref.search('title').first
+    attrib = pref.search('blockquote').last
+    attrib_text =  attrib.inner_text.gsub(/\s+/,' ')
 
-  # Some formatting issues we need to modify
-  attrib_text.gsub!(/Paul y Sarah/, 'Paul <?latex \textup{>y<?latex } > Sarah')
-  attrib_text.gsub!(/Merkley (CEO.*)/, 'Merkley <citetitle>\1</citetitle>')
-  attrib_text.gsub!(/Wolf (Ins.*)/, 'Wolf <citetitle>\1</citetitle>')
+    # Some formatting issues we need to modify
+    attrib_text.gsub!(/Paul y Sarah/, 'Paul <?latex \textup{>y<?latex } > Sarah')
+    attrib_text.gsub!(/Merkley,? (CEO.*)/, 'Merkley <citetitle>\1</citetitle>')
+    attrib_text.gsub!(/Wolf (Ins.*)/, 'Wolf <citetitle>\1</citetitle>')
 
-  attrib.remove
-  title.after('<blockquote><attribution>%s</attribution></blockquote>' % attrib_text)
-  log 1, 'Moved: %s' % attrib_text
+    attrib.remove
+    title.after('<blockquote><attribution>%s</attribution><para/></blockquote>' % attrib_text)
+    log 1, 'Moved: %s' % attrib_text
+  end
 end
 
-log 0, 'Replace legal info by the information assembled by our publisher'
-if legal = File.open('extra/es/legal_info.xml', 'r').read rescue nil
+if legal = File.open('extra/%s/legal_info.xml' % lang, 'r').read rescue nil
+  log 0, 'Replace legal info by the information assembled by our publisher'
   xml.search('colophon').first.inner_html = legal
+else
+  log 0, ' -!- Not including the %s legal_info text' % lang
 end
 
-log 0, 'Add a colophon at the end'
 # Doing this the dirty, non-DocBooky way: I'm adding a large <?latex
 # ... ?> section to the last appendix. This should probably go in the
 # <colophon> section, but it's already used.
@@ -57,8 +61,11 @@ log 0, 'Add a colophon at the end'
 # A cleaner way would be to replace the <xsl:param
 # name="latex.enddocument"> section in pdf_es.xsl — But it gets
 # trickier :-Þ
-if colophon = File.open('extra/es/colophon.tex', 'r').read rescue nil
+if colophon = File.open('extra/%s/colophon.tex' % lang, 'r').read rescue nil
+  log 0, 'Add a colophon at the end'
   xml.search('appendix').last.search('para').last.after('<?latex %s ?>' % colophon)
+else
+  log 0, ' -!- Not including the %s colophon text' % lang
 end