Sha256: aecc30dad8795d15c6875636d24fa029bed99fb76fe8c3f6439845196bb03482

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

module TranslatableRecords
  module ActiveRecord
    module Translatable
      extend ActiveSupport::Concern
 
      def with_locale(locale)
        @locale = locale.to_sym
      end
 
      def build_translations
        I18n.available_locales.each { |locale| translations.build locale: locale.to_s unless translations.find_by_locale(locale) }
      end   
 
      protected
 
      def current_locale
        @locale || I18n.locale
      end
 
      def translation_by_locale(locale)
        translations.find { |t| t.locale == locale.to_s } || translations.find_by_locale(locale)
      end
 
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translatable_records-1.0.7 lib/translatable_records/active_record/translatable.rb