Sha256: d1dc84cd018090b5f2612cd1f16c095bd276a3849e34b457796f323d4099cd4f
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Globalize mattr_accessor :available_locales def self.valid_locale?(loc) return false unless loc available_locales.include?(loc.to_sym) end end Globalize::ActiveRecord::ClassMethods.module_eval do def define_translations_reader_with_locale_suffix(name) define_translations_reader_without_locale_suffix(name) Globalize.available_locales.each do |locale| define_method :"#{name}_#{locale}" do read_attribute(name, {locale: locale}) end end end alias_method_chain :define_translations_reader, :locale_suffix def define_translations_writer_with_locale_suffix(name) define_translations_writer_without_locale_suffix(name) Globalize.available_locales.each do |locale| define_method :"#{name}_#{locale}=" do |value| changed_attributes[:"#{name}_#{locale}"] = value unless value == read_attribute(name, {locale: locale}) write_attribute(name, value, {locale: locale}) end end end alias_method_chain :define_translations_writer, :locale_suffix end Globalize::ActiveRecord::Translation.attr_accessible :locale
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ab_admin-0.4.0 | lib/ab_admin/hooks/globalize_hooks.rb |