lib/review/webtocprinter.rb in review-2.0.0 vs lib/review/webtocprinter.rb in review-2.1.0

- old
+ new

@@ -1,6 +1,7 @@ require 'review/tocprinter' +require 'review/i18n' module ReVIEW class WEBTOCPrinter < TOCPrinter include HTMLUtils @@ -20,11 +21,17 @@ @out.puts '</ul>' end def print_part(part) if part.number - @out.puts "<li>#{h(part.title)}\n<ul>\n" + if part.file? + ext = part.book.config["htmlext"] || "html" + path = part.path.sub(/\.re/, "."+ext) + @out.puts "<li><a href=\"#{path}\">#{h(I18n.t("part_short", part.number) + " " + part.title)}</a>\n<ul>\n" + else + @out.puts "<li>#{h(I18n.t("part_short", part.number) + " " + part.title)}\n<ul>\n" + end end part.each_chapter do |chap| print_chapter(chap) end if part.number @@ -35,10 +42,10 @@ def print_chapter(chap) chap_node = TOCParser.chapter_node(chap) ext = chap.book.config["htmlext"] || "html" path = chap.path.sub(/\.re/, "."+ext) if chap_node.number && chap.on_CHAPS? - label = "#{chap.number} #{chap.title}" + label = "#{I18n.t("chapter_short", chap.number)} #{chap.title}" else label = chap.title end @out.puts "<li><a href=\"#{path}\">#{h(label)}</a></li>\n" end