Class: PhraseApp::InContextEditor::FallbackKeysFetcher
- Inherits:
-
Object
- Object
- PhraseApp::InContextEditor::FallbackKeysFetcher
- Defined in:
- lib/phraseapp-in-context-editor-ruby/fallback_keys_fetcher.rb
Class Method Summary collapse
Class Method Details
.extract_fallback_keys(key, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/phraseapp-in-context-editor-ruby/fallback_keys_fetcher.rb', line 5 def self.extract_fallback_keys(key, ) fallback_items = [] if .has_key?(:default) if [:default].kind_of?(Array) fallback_items = [:default] else fallback_items << [:default] end end return fallback_items.map{ |item| process_fallback_item(item, key, ) }.flatten.uniq end |
.process_fallback_item(item, key, options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/phraseapp-in-context-editor-ruby/fallback_keys_fetcher.rb', line 18 def self.process_fallback_item(item, key, ) fallback_keys = [] if item.kind_of?(Symbol) fallback_key_name = item.to_s if .has_key?(:scope) if [:scope].is_a?(Array) fallback_key_name = "#{[:scope].join(".")}.#{item}" else fallback_key_name = "#{[:scope]}.#{item}" end end fallback_keys << fallback_key_name if key == "helpers.label.#{fallback_key_name}" # http://apidock.com/rails/v3.1.0/ActionView/Helpers/FormHelper/label fallback_keys << "activerecord.attributes.#{fallback_key_name}" end if key.start_with?("simple_form.") # special treatment for simple form fallback_keys << "activerecord.attributes.#{item}" end end return fallback_keys end |