Sha256: a30fe499968f1d666fc53d3832a27ece28ccc62e0831cb63c3256b77111d5b18
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
module Pomo class Translation FUZZY_REGEX = /^\s*fuzzy\s*$/ attr_accessor :msgid, :msgstr, :comment 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 #simple form send("#{to}=",send(to).to_s+text) end end def to_hash {:msgid=>msgid,:msgstr=>msgstr,:comment=>comment}.reject{|k,value|value.nil?} end def complete? not msgid.to_s.strip.empty? and not msgstr.nil? end def fuzzy? comment =~ FUZZY_REGEX end def fuzzy=(value) if value and not fuzzy? add_text "\nfuzzy", :to=>:comment else self.comment = comment.to_s.split(/$/).reject{|line|line=~FUZZY_REGEX}.join("\n") end end def plural? msgid.is_a? Array or msgstr.is_a? Array end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grosser-pomo-0.4.1 | lib/pomo/translation.rb |
grosser-pomo-0.5.0 | lib/pomo/translation.rb |