Class: Pseudolocalization::I18n::Backend
- Inherits:
-
Object
- Object
- Pseudolocalization::I18n::Backend
- Defined in:
- lib/pseudolocalization.rb
Instance Attribute Summary collapse
-
#ignores ⇒ Object
Returns the value of attribute ignores.
-
#original_backend ⇒ Object
readonly
Returns the value of attribute original_backend.
Instance Method Summary collapse
-
#initialize(original_backend) {|_self| ... } ⇒ Backend
constructor
A new instance of Backend.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
- #translate(locale, key, options) ⇒ Object
- #translations ⇒ Object
Constructor Details
#initialize(original_backend) {|_self| ... } ⇒ Backend
Returns a new instance of Backend.
10 11 12 13 14 |
# File 'lib/pseudolocalization.rb', line 10 def initialize(original_backend) @original_backend = original_backend @ignores = [] yield self if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pseudolocalization.rb', line 16 def method_missing(name, *args, &block) if respond_to_missing?(name) original_backend.public_send(name, *args, &block) else super end end |
Instance Attribute Details
#ignores ⇒ Object
Returns the value of attribute ignores.
8 9 10 |
# File 'lib/pseudolocalization.rb', line 8 def ignores @ignores end |
#original_backend ⇒ Object (readonly)
Returns the value of attribute original_backend.
7 8 9 |
# File 'lib/pseudolocalization.rb', line 7 def original_backend @original_backend end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
24 25 26 |
# File 'lib/pseudolocalization.rb', line 24 def respond_to_missing?(name, include_private = false) original_backend.respond_to?(name) || super end |
#translate(locale, key, options) ⇒ Object
28 29 30 31 32 |
# File 'lib/pseudolocalization.rb', line 28 def translate(locale, key, ) return original_backend.translate(locale, key, ) if key_ignored?(key) ::Pseudolocalization::I18n::Pseudolocalizer.pseudolocalize(original_backend.translate(locale, key, )) end |
#translations ⇒ Object
34 35 36 37 38 39 |
# File 'lib/pseudolocalization.rb', line 34 def translations original = original_backend.translations original.transform_values do |locale_translations| pseudolocalize_node(locale_translations) end end |