X-Git-Url: https://pere.pagekite.me/gitweb/text-madewithcc.git/blobdiff_plain/fc3df46b45c58b0048e7bdc65b75dfde0cf4efee..139103cec43480c2c29c5fc27db6ea0457cb7d9d:/fixup-docbook-translated.rb
diff --git a/fixup-docbook-translated.rb b/fixup-docbook-translated.rb
index 1d7e3a0..d933346 100644
--- a/fixup-docbook-translated.rb
+++ b/fixup-docbook-translated.rb
@@ -21,43 +21,54 @@ 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, 'replace images with translated versions'
-xml.search('imagedata').each do |img|
- # Included images are in the 'Pictures' directory. Translated images
- # are in Pictures/[langcode]/. Only translated images need to be
- # included.
- orig_img = img.attributes['fileref'].text
- trans_img = orig_img.gsub(/Pictures/, "Pictures/#{lang}")
- next if orig_img == trans_img
+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+/,' ')
- if File.exists?(trans_img)
- log 1, 'Replaced %s by %s' % [orig_img, trans_img]
- img.set_attribute('fileref', trans_img)
+ # Some formatting issues we need to modify
+ attrib_text.gsub!(/Paul y Sarah/, 'Paul y Sarah')
+ attrib_text.gsub!(/Merkley,? (CEO.*)/, 'Merkley
' % attrib_text) + log 1, 'Moved: %s' % attrib_text end 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+/,' ') - - # Some formatting issues we need to modify - attrib_text.gsub!(/Paul y Sarah/, 'Paul y Sarah') - attrib_text.gsub!(/Merkley (CEO.*)/, 'Merkley%s
' % attrib_text) - log 1, 'Moved: %s' % attrib_text +# Doing this the dirty, non-DocBooky way: I'm adding a large section to the last appendix. This should probably go in the +#%s