Class: GlobalizeTranslationSuggestion

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/globalize_translation_suggestion.rb

Instance Method Summary collapse

Instance Method Details

#interpolations_required?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/globalize_translation_suggestion.rb', line 9

def interpolations_required?
  original_text = self.globalize_translation.value

  interpolations = original_text.scan(/%?\{.+?\}/)
  unless interpolations.empty?
    translations_interpolation = extract_interpolations(translation)

    if interpolations.sort != translations_interpolation.sort
      errors.add :interpolations, "Translation should include all interpolation elements: #{interpolations.join(", ")}"
    end
  end
end