# -*- coding: utf-8 -*- # # Copyright (C) 2012 Kouhei Sutou # Copyright (C) 2010 Eddie Lau # # License: Ruby's or LGPL # # This library is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . require 'gettext/tools/msgmerge' class TestToolsMsgMerge < Test::Unit::TestCase class TestPoData < self def setup @po_data = GetText::Tools::MsgMerge::PoData.new end def test_generate_po header_entry_comment = "# header entry comment." header_entry = "header entry" comment = "#: test.rb:10" msgid = "Hello" msgstr = "Salut" expected_po = <, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\\n" "POT-Creation-Date: #{@pot_formatted_time}\\n" "PO-Revision-Date: #{@pot_formatted_time}\\n" "Last-Translator: FULL NAME \\n" "Language-Team: LANGUAGE \\n" "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=UTF-8\\n" "Content-Transfer-Encoding: 8bit\\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n" #: hello.rb:1 msgid "Hello" msgstr "" #: hello.rb:2 msgid "World" msgstr "" EOP end def po_header(creation_date, revision_date) <<-EOH # Hello Application. # Copyright (C) 2012 Kouhei Sutou # This file is distributed under the same license as the Hello package. # Kouhei Sutou , 2012. # msgid "" msgstr "" "Project-Id-Version: Hello 1.0.0\\n" "POT-Creation-Date: #{creation_date}\\n" "PO-Revision-Date: #{revision_date}\\n" "Last-Translator: Kouhei Sutou \\n" "Language-Team: Japanese \\n" "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=UTF-8\\n" "Content-Transfer-Encoding: 8bit\\n" "Plural-Forms: nplurals=1; plural=0;\\n" EOH end def po_content <<-EOP #{po_header(@po_formatted_time, @po_formatted_time)} #: hello.rb:1 msgid "World" msgstr "Translated World" EOP end class TestFuzzy < self def test_header_message @msgmerge.run(@po_file_path, @pot_file_path, "--output", @po_file_path) assert_equal(<<-EOP, File.read(@po_file_path)) #{po_header(@pot_formatted_time, @po_formatted_time)} #: hello.rb:1 msgid "Hello" msgstr "" #: hello.rb:2 msgid "World" msgstr "Translated World" EOP end end end end