class GetPomo::Translation
Constants
- FUZZY_REGEX
- OBSOLETE_REGEX
Attributes
comment[RW]
msgctxt[RW]
msgid[RW]
msgstr[RW]
Public Instance Methods
add_text(text,options)
click to toggle source
# File lib/get_pomo/translation.rb, line 7 def add_text(text,options) to = options[:to] if to.to_sym == :msgid_plural self.msgid = [msgid] unless msgid.is_a? Array msgid[1] = msgid[1].to_s + text elsif to.to_s =~ /^msgstr\[(\d)\]$/ self.msgstr ||= [] msgstr[$1.to_i] = msgstr[$1.to_i].to_s + text else raise GetPomo::InvalidMethod, "No method found for #{to}" unless self.respond_to?(to) send("#{to}=",send(to).to_s+text) end end
complete?()
click to toggle source
# File lib/get_pomo/translation.rb, line 30 def complete? (not msgid.nil? and not msgstr.nil?) or obsolete? end
fuzzy=(value)
click to toggle source
# File lib/get_pomo/translation.rb, line 42 def fuzzy=(value) if value and not fuzzy? add_text "\n#, fuzzy", :to=>:comment else self.comment = comment.to_s.split(/$/).reject{|line|line=~FUZZY_REGEX}.join("\n") end end
fuzzy?()
click to toggle source
# File lib/get_pomo/translation.rb, line 34 def fuzzy? !!(comment =~ FUZZY_REGEX) end
header?()
click to toggle source
# File lib/get_pomo/translation.rb, line 58 def header? msgid == "" end
obsolete?()
click to toggle source
# File lib/get_pomo/translation.rb, line 38 def obsolete? !!(comment =~ OBSOLETE_REGEX) end
plural?()
click to toggle source
# File lib/get_pomo/translation.rb, line 50 def plural? msgid.is_a? Array or msgstr.is_a? Array end
singular?()
click to toggle source
# File lib/get_pomo/translation.rb, line 54 def singular? !plural? end
to_hash()
click to toggle source
# File lib/get_pomo/translation.rb, line 21 def to_hash { :msgctxt => msgctxt, :msgid => msgid, :msgstr => msgstr, :comment => comment }.reject { |_,value| value.nil? } end