Class: ExtractI18n::HTMLExtractor::Match::PlainTextMatch
Instance Attribute Summary
Attributes inherited from BaseMatch
Attributes inherited from NodeMatch
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseMatch
Methods inherited from NodeMatch
#initialize, #to_s, #translation_key_object
Constructor Details
This class inherits a constructor from ExtractI18n::HTMLExtractor::Match::BaseMatch
Class Method Details
.create(document, node) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/extract_i18n/html_extractor/match/plain_text_match.rb', line 5 def self.create(document, node) return nil if node.name.start_with?('script') node.text.split(/\@\@(=?)[a-z0-9\-]+\@\@/).map! do |text| new(document, node, text.strip) if !text.nil? && !text.empty? end end |
Instance Method Details
#replace_text!(key, i18n_t) ⇒ Object
12 13 14 15 |
# File 'lib/extract_i18n/html_extractor/match/plain_text_match.rb', line 12 def replace_text!(key, i18n_t) document.erb_directives[key] = i18n_t node.content = node.content.gsub(text, "@@=#{key}@@") end |