Method: GetText::POEntry#merge

Defined in:
lib/gettext/po_entry.rb

#merge(other) ⇒ Object

Merges two translation targets with the same msgid and returns the merged result. If one is declared as plural and the other not, then the one with the plural wins.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/gettext/po_entry.rb', line 144

def merge(other)
  return self unless other
  unless mergeable?(other)
    message = "Translation targets do not match: \n" +
      "  self: #{self.inspect}\n  other: '#{other.inspect}'"
    raise ParseError, message
  end
  if other.msgid_plural && !msgid_plural
    res = other
    unless res.references.include?(references[0])
      res.references += references
      res.add_comment(extracted_comment)
    end
  else
    res = self
    unless res.references.include?(other.references[0])
      res.references += other.references
      res.add_comment(other.extracted_comment)
    end
  end
  res
end