Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/gettext/tools/rmsgmerge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def generate_po_entry(msgid)
id = msgid.gsub(/"/, '\"').gsub(/\r/, '')
msgstr = @msgid2msgstr[msgid].gsub(/"/, '\"').gsub(/\r/, '')

if id.include?("\004")
ids = id.split(/\004/)
context = ids[0]
id = ids[1]
str << "msgctxt " << __conv(context) << "\n"
end

if id.include?("\000")
ids = id.split(/\000/)
str << "msgid " << __conv(ids[0]) << "\n"
Expand Down
19 changes: 19 additions & 0 deletions test/tools/test_rmsgmerge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# encoding: utf-8

require 'testlib/helper'
require 'gettext/tools/rmsgmerge'

class TestRMsgMerge < Test::Unit::TestCase
def test_po_data_should_generate_msgctxt
msg_id = "Context\004Translation"

po_data = GetText::RMsgMerge::PoData.new
po_data[msg_id] = "Translated"
po_data.set_comment(msg_id, "#no comment")

result = po_data.generate_po_entry(msg_id)

expected = "#no comment\nmsgctxt \"Context\"\nmsgid \"Translation\"\nmsgstr \"Translated\"\n\n"
assert_equal expected, result
end
end