test/tools/test_msgmerge.rb in gettext-2.3.0 vs test/tools/test_msgmerge.rb in gettext-2.3.1

- old
+ new

@@ -35,10 +35,11 @@ expected_po = <<EOP #{header_entry_comment} msgid \"\" msgstr \"\" \"#{header_entry}\\n\" + #{comment} msgid \"#{msgid}\" msgstr \"#{msgstr}\" EOP @@ -64,10 +65,11 @@ expected_po = <<EOP #{header_entry_comment} msgid \"\" msgstr \"\" \"#{header_entry}\\n\" + #{obsolete_comment} EOP po = GetText::Tools::MsgMerge::PoData.new po.set_comment("", header_entry_comment) @@ -75,22 +77,57 @@ po.set_comment(:last, obsolete_comment) assert_equal(expected_po, po.generate_po) end - def test_msgctxt - msg_id = "Context\004Translation" - @po_data[msg_id] = "Translated" - @po_data.set_comment(msg_id, "#no comment") + def test_generate_po_msgid_plural_and_empty_msgstr + msgid = "Singular message\000Plural message" - entry = @po_data.generate_po_entry(msg_id) - assert_equal(<<-'EOE', entry) + @po_data[""] = "Plural-Forms: nplurals=2; plural=n != 1;\\n" + @po_data[msgid] = "" + @po_data.set_comment(msgid, "# plural message") + actual_po = @po_data.generate_po_entry(msgid) + expected_po = <<'EOE' +# plural message +msgid "Singular message" +msgid_plural "Plural message" +msgstr[0] "" +msgstr[1] "" +EOE + assert_equal(expected_po, actual_po) + end + + class TestGeneratePoEntry < self + def test_msgid_plural + msgid = "Singular message\000Plural message" + + @po_data[msgid] = "Singular translation\000Plural translation" + @po_data.set_comment(msgid, "#plural message") + actual_po = @po_data.generate_po_entry(msgid) + expected_po = <<'EOE' +#plural message +msgid "Singular message" +msgid_plural "Plural message" +msgstr[0] "Singular translation" +msgstr[1] "Plural translation" +EOE + assert_equal(expected_po, actual_po) + end + + def test_msgctxt + msg_id = "Context\004Translation" + @po_data[msg_id] = "Translated" + @po_data.set_comment(msg_id, "#no comment") + + entry = @po_data.generate_po_entry(msg_id) + assert_equal(<<-'EOE', entry) #no comment msgctxt "Context" msgid "Translation" msgstr "Translated" EOE + end end end class TestMerge < self include GetTextTestUtils @@ -175,9 +212,10 @@ end def po_content <<-EOP #{po_header(@po_formatted_time, @po_formatted_time)} + #: hello.rb:1 msgid "World" msgstr "Translated World" EOP end