Module: I18nliner::Extensions::Core
- Defined in:
- lib/i18nliner/extensions/core.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#interpolate_hash_with_html_safety(string, values) ⇒ Object
can’t super this one yet :-/.
- #translate(*args) ⇒ Object (also: #t, #t!, #translate!)
Class Method Details
.extended(base) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/i18nliner/extensions/core.rb', line 46 def self.extended(base) base.instance_eval do alias :interpolate_hash_without_html_safety :interpolate_hash alias :interpolate_hash :interpolate_hash_with_html_safety end end |
Instance Method Details
#interpolate_hash_with_html_safety(string, values) ⇒ Object
can’t super this one yet :-/
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/i18nliner/extensions/core.rb', line 34 def interpolate_hash_with_html_safety(string, values) if string.html_safe? || values.values.any?{ |v| v.is_a?(ActiveSupport::SafeBuffer) } string = ERB::Util.h(string) unless string.html_safe? values.each do |key, value| values[key] = ERB::Util.h(value) unless value.html_safe? end interpolate_hash_without_html_safety(string.to_str, values).html_safe else interpolate_hash_without_html_safety(string, values) end end |
#translate(*args) ⇒ Object Also known as: t, t!, translate!
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/i18nliner/extensions/core.rb', line 8 def translate(*args) key, = *CallHelpers.infer_arguments(args) scope = .delete(:i18nliner_scope) || Scope.root inferred_key = .delete(:i18nliner_inferred_key) key = CallHelpers.normalize_key(key, scope, inferred_key, [:scope]) if default = [:default] [:default] = CallHelpers.normalize_default(default, ) end wrappers = .delete(:wrappers) || .delete(:wrapper) result = super(key, ) if wrappers result = apply_wrappers(result, wrappers) end result rescue ArgumentError raise end |