Skip to content

Commit c90f90a

Browse files
authored
Merge pull request #218 from znz/japanese-index-labels
インデックスページへのリンクラベルをカタログ経由にしてリンク先タイトルと揃える
2 parents caeda4c + da34555 commit c90f90a

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

lib/bitclust/rdcompiler.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def initialize(urlmapper, hlevel = 1, opt = {})
3232
@type = nil
3333
@method = nil
3434
@option = opt.dup
35-
init_message_catalog(@catalog)
35+
init_message_catalog(@catalog || MessageCatalog.new({}, 'C'))
3636
end
3737

3838
def compile(src)
@@ -449,9 +449,9 @@ def bracket_link(link, label = nil, frag = nil)
449449
protect(link) {
450450
case arg
451451
when '/', '_index'
452-
label = 'All libraries'
452+
label = _('Library Index')
453453
when '_builtin'
454-
label = 'Builtin libraries'
454+
label = _('Builtin Library')
455455
end
456456
library_link(arg, label, frag)
457457
}
@@ -463,7 +463,7 @@ def bracket_link(link, label = nil, frag = nil)
463463
protect(link) {
464464
case arg
465465
when '/', '_index'
466-
arg, label = '', 'All C API'
466+
arg, label = '', _('Function Index')
467467
end
468468
function_link(arg, label || arg, frag)
469469
}

test/test_rdcompiler.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,12 @@ def test_invalid_case
696696
"instance method" => ['[[m:String#dump]]', '<a href="dummy/method/String/i/dump">String#dump</a>'],
697697
"indexer" => ['[[m:String#[] ]]', '<a href="dummy/method/String/i/=5b=5d">String#[]</a>'],
698698
"C API" => ['[[f:rb_ary_new3]]', '<a href="dummy/function/rb_ary_new3">rb_ary_new3</a>'],
699-
"C API root" => ['[[f:/]]', '<a href="dummy/function/">All C API</a>'],
700-
"C API index" => ['[[f:_index]]', '<a href="dummy/function/">All C API</a>'],
699+
"C API root" => ['[[f:/]]', '<a href="dummy/function/">Function Index</a>'],
700+
"C API index" => ['[[f:_index]]', '<a href="dummy/function/">Function Index</a>'],
701701
"standard library" => ['[[lib:jcode]]', '<a href="dummy/library/jcode">jcode</a>'],
702+
"library root" => ['[[lib:/]]', '<a href="dummy/library/">Library Index</a>'],
703+
"library index" => ['[[lib:_index]]', '<a href="dummy/library/_index">Library Index</a>'],
704+
"builtin library" => ['[[lib:_builtin]]', '<a href="dummy/library/_builtin">Builtin Library</a>'],
702705
"man command" => ['[[man:tr(1)]]', '<a class="external" href="http://www.opengroup.org/onlinepubs/009695399/utilities/tr.html">tr(1)</a>'],
703706
"man header" => ['[[man:sys/socket.h(header)]]', '<a class="external" href="http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html">sys/socket.h(header)</a>'],
704707
"man system call" => ['[[man:fopen(3linux)]]', '<a class="external" href="http://man7.org/linux/man-pages/man3/fopen.3.html">fopen(3linux)</a>'],
@@ -718,6 +721,17 @@ def test_bracket_link(data)
718721
assert_equal(expected, @c.send(:compile_text, target), target)
719722
end
720723

724+
data("library root" => ['[[lib:/]]', '<a href="dummy/library/">ライブラリ一覧</a>'],
725+
"builtin library" => ['[[lib:_builtin]]', '<a href="dummy/library/_builtin">組み込みライブラリ</a>'],
726+
"C API root" => ['[[f:/]]', '<a href="dummy/function/">関数一覧</a>'])
727+
def test_bracket_link_with_catalog(data)
728+
target, expected = data
729+
prefix = File.expand_path('../data/bitclust/catalog', __dir__)
730+
catalog = BitClust::MessageCatalog.load_with_locales(prefix, ['ja_JP.UTF-8'])
731+
compiler = BitClust::RDCompiler.new(@u, 1, {:database => @db, :catalog => catalog})
732+
assert_equal(expected, compiler.send(:compile_text, target), target)
733+
end
734+
721735
data("doc" => ['[[d:hoge/bar]]', '<a href="dummy/hoge/bar">.*</a>'],
722736
"ref doc" => ['[[ref:d:hoge/bar#frag]]', '<a href="dummy/hoge/bar#frag">.*</a>'],
723737
"ref class" => ['[[ref:c:Hoge#frag]]', '<a href="dummy/class/Hoge#frag">.*</a>'],

0 commit comments

Comments
 (0)