Class: Formtastic::Localizer

Inherits:
Object
  • Object
show all
Defined in:
lib/formtastic/localizer.rb

Overview

Implementation for looking up localized values within Formtastic using I18n, if no explicit value (like the :label option) is set and I18n-lookups are enabled in the configuration.

You can subclass this to implement your own Localizer, and configure Formtastic to use this localizer with:

Formtastic::FormBuilder.i18n_localizer

Enabled/disable i18n lookups completely with:

Formtastic::FormBuilder.i18n_lookups_by_default = true/false

Lookup priority:

'formtastic.%type.%model.%action.%attribute' 'formtastic.%type.%model.%attribute' 'formtastic.%type.%attribute'

Example:

'formtastic.labels.post.edit.title' 'formtastic.labels.post.title' 'formtastic.labels.title'

Defined Under Namespace

Classes: Cache

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_builder) ⇒ Localizer



55
56
57
# File 'lib/formtastic/localizer.rb', line 55

def initialize(current_builder)
  self.builder = current_builder 
end

Instance Attribute Details

#builderObject

Returns the value of attribute builder



49
50
51
# File 'lib/formtastic/localizer.rb', line 49

def builder
  @builder
end

Class Method Details

.cacheObject



51
52
53
# File 'lib/formtastic/localizer.rb', line 51

def self.cache
  @cache ||= Cache.new
end