Sha256: 4433833cb7a8a3b3a6b00cd1774c161ca2cd5ccbd79fdd996cada4c6fccd3f5f
Contents?: true
Size: 628 Bytes
Versions: 4
Compression:
Stored size: 628 Bytes
Contents
module TranslatableRecords module ActiveRecord module Translatable extend ActiveSupport::Concern def with_locale(locale) @current_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 @current_locale || I18n.locale end def translation_by_locale(locale) translations.to_a.find { |t| t.locale == locale.to_s } || translations.find_by_locale(locale) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems