Class: ExtractI18n::Slimkeyfy::JsWord
- Defined in:
- lib/extract_i18n/slimkeyfy/word.rb
Instance Attribute Summary
Attributes inherited from Word
Instance Method Summary collapse
- #extract_arguments(translation) ⇒ Object
-
#initialize(*args) ⇒ JsWord
constructor
A new instance of JsWord.
Methods inherited from Word
#as_list, #extract_updated_key, for, #head, #tail, #unindented_line
Constructor Details
#initialize(*args) ⇒ JsWord
Returns a new instance of JsWord.
71 72 73 74 |
# File 'lib/extract_i18n/slimkeyfy/word.rb', line 71 def initialize(*args) super @use_absolute_key = true end |
Instance Method Details
#extract_arguments(translation) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/extract_i18n/slimkeyfy/word.rb', line 76 def extract_arguments(translation) args = {} translation.scan(/\{\{([^}]*)\}\}/).each_with_index do |stripped_arg, index| arg = Regexp.last_match[0] key = arg[/\w+/] key += index.to_s if index > 0 translation = translation.gsub(arg, "{#{key}}") args[key] = stripped_arg[0] end [args, translation] end |