Module: Globalize::Accessors

Defined in:
lib/releaf/rails_ext/globalize-accessors.rb

Defined Under Namespace

Modules: InstanceMethods

Instance Method Summary collapse

Instance Method Details

#globalize_accessors(options = {}) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/releaf/rails_ext/globalize-accessors.rb', line 4

def globalize_accessors(options = {})
  options.reverse_merge!(:locales => I18n.available_locales, :attributes => translated_attribute_names)
  class_attribute :globalize_locales, :globalize_attribute_names, :instance_writer => false

  self.globalize_locales = options[:locales]
  self.globalize_attribute_names = []

  each_attribute_and_locale(options) do |attr_name, locale|
    define_accessors(attr_name, locale)
  end

  include InstanceMethods
end

#localized_attr_name_for(attr_name, locale) ⇒ Object


18
19
20
# File 'lib/releaf/rails_ext/globalize-accessors.rb', line 18

def localized_attr_name_for(attr_name, locale)
  "#{attr_name}_#{locale.to_s.underscore}"
end