Sha256: 7d8f32324d4fe6f6b9a5ea3876376ad5b8c7ef4822786174b5a959fe39485411
Contents?: true
Size: 933 Bytes
Versions: 1
Compression:
Stored size: 933 Bytes
Contents
require 'i18n' require 'lost_in_translations/base' require 'lost_in_translations/ruby' require 'lost_in_translations/config' require 'lost_in_translations/translator' require 'lost_in_translations/active_record' module LostInTranslations def self.included(base_class) if defined?(::ActiveRecord::Base) && base_class.ancestors.include?(::ActiveRecord::Base) base_class.include LostInTranslations::ActiveRecord else base_class.include Ruby end end def self.config @config ||= Config.new('translation_data', Translator) end def self.translate(*args) config.translator.translate(*args) end def self.define_translation_methods(object, *fields) fields.each do |field| object.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{field} translate(:#{field}, I18n.locale) end RUBY end end def self.configure yield(config) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lost_in_translations-1.2.0 | lib/lost_in_translations.rb |