Class: BaseTranslationStore
- Inherits:
-
Object
- Object
- BaseTranslationStore
- Defined in:
- lib/core/base_translation_store.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #add_translation(key, value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ BaseTranslationStore
constructor
A new instance of BaseTranslationStore.
- #serialize ⇒ Object
- #start_new_context(new_context) ⇒ Object
Constructor Details
#initialize ⇒ BaseTranslationStore
Returns a new instance of BaseTranslationStore.
5 6 7 8 |
# File 'lib/core/base_translation_store.rb', line 5 def initialize @context_maps = {} @context_array = [] end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/core/base_translation_store.rb', line 3 def context @context end |
Instance Method Details
#add_translation(key, value) ⇒ Object
26 27 28 |
# File 'lib/core/base_translation_store.rb', line 26 def add_translation( key, value ) context_map() << [key, value] end |
#each(&block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/core/base_translation_store.rb', line 10 def each( &block ) @context_array.each do |context| @context_maps[context].each do |key_value_pair| key_name, key_value = *key_value_pair yield context, key_name, key_value end end end |
#serialize ⇒ Object
30 31 32 |
# File 'lib/core/base_translation_store.rb', line 30 def serialize raise "Implement me" end |
#start_new_context(new_context) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/core/base_translation_store.rb', line 19 def start_new_context( new_context ) # Rails does not allow contexts that begin with an underscore. If we are # converting erb partials that start with underscores we want to ensure # we strip those so that we handle Rails i18n conventions properly. @context = new_context.gsub(/(^|\/)_/, '\1') end |