From 5d81fb2a1ad7de065f325242d2e4d8cba04647c8 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Mon, 18 Dec 2017 17:21:56 +0900 Subject: [PATCH 1/2] introduce chapter_quote_without_number, hd_quote, hd_quote_without_number --- lib/review/book/index.rb | 6 +++++- lib/review/htmlbuilder.rb | 4 ++-- lib/review/i18n.rb | 6 ++++++ lib/review/i18n.yml | 15 ++++++++++++--- lib/review/idgxmlbuilder.rb | 4 ++-- lib/review/latexbuilder.rb | 6 +++--- lib/review/topbuilder.rb | 4 ++-- 7 files changed, 32 insertions(+), 13 deletions(-) diff --git a/lib/review/book/index.rb b/lib/review/book/index.rb index f54b5134c..a81789831 100644 --- a/lib/review/book/index.rb +++ b/lib/review/book/index.rb @@ -100,7 +100,11 @@ def title(id) end def display_string(id) - "#{number(id)}#{I18n.t('chapter_quote', title(id))}" + if number(id) + I18n.t('chapter_quote', [number(id), title(id)]) + else + I18n.t('chapter_quote_without_number', title(id)) + end end end diff --git a/lib/review/htmlbuilder.rb b/lib/review/htmlbuilder.rb index 09ff23e35..a9857f410 100644 --- a/lib/review/htmlbuilder.rb +++ b/lib/review/htmlbuilder.rb @@ -926,9 +926,9 @@ def inline_bib(id) def inline_hd_chap(chap, id) n = chap.headline_index.number(id) if chap.number and @book.config['secnolevel'] >= n.split('.').size - str = I18n.t('chapter_quote', "#{n} #{compile_inline(chap.headline(id).caption)}") + str = I18n.t('hd_quote', [n, compile_inline(chap.headline(id).caption)]) else - str = I18n.t('chapter_quote', compile_inline(chap.headline(id).caption)) + str = I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption)) end if @book.config['chapterlink'] anchor = 'h' + n.gsub('.', '-') diff --git a/lib/review/i18n.rb b/lib/review/i18n.rb index 36eaeb60a..b5444c55c 100644 --- a/lib/review/i18n.rb +++ b/lib/review/i18n.rb @@ -86,6 +86,12 @@ def update_localefile(path) @store[key].merge!(values) end end + + # check obsolete locale parameter + s = t('chapter_quote', ['__!@!NUMBER!@!__', '__!@!TITLE!@!__']) + if s !~ /__!@!NUMBER!@!__/ || s !~ /__!@!TITLE!@!__/ + ReVIEW.logger.warn %Q('chapter_quote' should take 2 '%s' (number and title).) + end end def update(user_i18n, locale = nil) diff --git a/lib/review/i18n.yml b/lib/review/i18n.yml index d9a83a06b..401344dac 100644 --- a/lib/review/i18n.yml +++ b/lib/review/i18n.yml @@ -10,7 +10,10 @@ ja: chapter: 第%d章 chapter_short: "%d" chapter_postfix: " " - chapter_quote: "「%s」" + chapter_quote: "%s「%s」" + chapter_quote_without_number: "「%s」" + hd_quote: "「%s %s」" + hd_quote_without_number: "「%s」" appendix: 付録%pA numberless_image: "図:" memo_head: ■メモ @@ -72,7 +75,10 @@ en: chapter: Chapter %d chapter_short: "%d" chapter_postfix: ". " - chapter_quote: '"%s"' + chapter_quote: '%s "%s"' + chapter_quote_without_number: '"%s"' + hd_quote: '"%s %s"' + hd_quote_without_number: '"%s"' appendix: Appendix %s numberless_image: "Figure:" memo_head: Note @@ -131,7 +137,10 @@ zh-TW: chapter: 第%d章 chapter_short: "%d" chapter_postfix: " " - chapter_quote: "「%s」" + chapter_quote: "%s「%s」" + chapter_quote_without_number: "「%s」" + hd_quote: "「%s %s」" + hd_quote_without_number: "「%s」" appendix: 附錄%s numberless_image: "圖:" format_number: "%s.%d" diff --git a/lib/review/idgxmlbuilder.rb b/lib/review/idgxmlbuilder.rb index 5f4c9a03d..c634cddc5 100644 --- a/lib/review/idgxmlbuilder.rb +++ b/lib/review/idgxmlbuilder.rb @@ -1124,10 +1124,10 @@ def inline_hd_chap(chap, id) if chap.number n = chap.headline_index.number(id) if @book.config['secnolevel'] >= n.split('.').size - return I18n.t('chapter_quote', "#{n} #{compile_inline(chap.headline(id).caption)}") + return I18n.t('hd_quote', [n, compile_inline(chap.headline(id).caption)]) end end - I18n.t('chapter_quote', compile_inline(chap.headline(id).caption)) + I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption)) end def inline_recipe(id) diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb index 4d4e2086a..7c686440d 100644 --- a/lib/review/latexbuilder.rb +++ b/lib/review/latexbuilder.rb @@ -836,9 +836,9 @@ def inline_bib(id) def inline_hd_chap(chap, id) n = chap.headline_index.number(id) if chap.number and @book.config['secnolevel'] >= n.split('.').size - str = I18n.t('chapter_quote', "#{chap.headline_index.number(id)} #{compile_inline(chap.headline(id).caption)}") + str = I18n.t('hd_quote', [chap.headline_index.number(id), compile_inline(chap.headline(id).caption)]) else - str = I18n.t('chapter_quote', compile_inline(chap.headline(id).caption)) + str = I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption)) end if @book.config['chapterlink'] anchor = n.gsub(/\./, '-') @@ -850,7 +850,7 @@ def inline_hd_chap(chap, id) def inline_column_chap(chapter, id) macro('reviewcolumnref', - I18n.t('chapter_quote', compile_inline(chapter.column(id).caption)), + I18n.t('hd_quote_without_number', compile_inline(chapter.column(id).caption)), column_label(id, chapter)) end diff --git a/lib/review/topbuilder.rb b/lib/review/topbuilder.rb index 7d26f8ca6..111c77d63 100644 --- a/lib/review/topbuilder.rb +++ b/lib/review/topbuilder.rb @@ -521,9 +521,9 @@ def inline_bib(id) def inline_hd_chap(chap, id) if chap.number n = chap.headline_index.number(id) - return I18n.t('chapter_quote', "#{n} #{compile_inline(chap.headline(id).caption)}") if @book.config['secnolevel'] >= n.split('.').size + return I18n.t('hd_quote', [n, compile_inline(chap.headline(id).caption)]) if @book.config['secnolevel'] >= n.split('.').size end - I18n.t('chapter_quote', compile_inline(chap.headline(id).caption)) + I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption)) end def noindent From 08758291daa204f0b4c862345c37ef3b6ddba4b4 Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Mon, 18 Dec 2017 17:38:45 +0900 Subject: [PATCH 2/2] apply column i18n string --- lib/review/builder.rb | 2 +- lib/review/i18n.yml | 3 +++ lib/review/latexbuilder.rb | 2 +- test/test_rstbuilder.rb | 2 +- test/test_topbuilder.rb | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/review/builder.rb b/lib/review/builder.rb index 4c85f2a29..fa74648e3 100644 --- a/lib/review/builder.rb +++ b/lib/review/builder.rb @@ -309,7 +309,7 @@ def inline_column(id) end def inline_column_chap(chapter, id) - chapter.column(id).caption + I18n.t('column', chapter.column(id).caption) end def inline_pageref(id) diff --git a/lib/review/i18n.yml b/lib/review/i18n.yml index 401344dac..f7726ed29 100644 --- a/lib/review/i18n.yml +++ b/lib/review/i18n.yml @@ -132,6 +132,9 @@ zh-TW: image: 圖 table: 表 list: List + column: "Column %s" + columnname: "Column" + column_head: "Column" part: 第%pR部份 part_short: "%pR" chapter: 第%d章 diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb index 7c686440d..a0378c1db 100644 --- a/lib/review/latexbuilder.rb +++ b/lib/review/latexbuilder.rb @@ -850,7 +850,7 @@ def inline_hd_chap(chap, id) def inline_column_chap(chapter, id) macro('reviewcolumnref', - I18n.t('hd_quote_without_number', compile_inline(chapter.column(id).caption)), + I18n.t('column', compile_inline(chapter.column(id).caption)), column_label(id, chapter)) end diff --git a/test/test_rstbuilder.rb b/test/test_rstbuilder.rb index afc49ed4d..72afc47af 100644 --- a/test/test_rstbuilder.rb +++ b/test/test_rstbuilder.rb @@ -347,7 +347,7 @@ def test_column_ref next level -------------------- -this is test. +this is コラム「test」. EOS diff --git a/test/test_topbuilder.rb b/test/test_topbuilder.rb index 954e48c8f..f5809ff9f 100644 --- a/test/test_topbuilder.rb +++ b/test/test_topbuilder.rb @@ -367,7 +367,7 @@ def test_column_ref ◆→終了:コラム←◆ ■H3■next level -this is test. +this is コラム「test」. EOS assert_equal expected, column_helper(review)