Sha256: a6d506b47a48f142e4bc4b5d679d6901d9f3f12d263d448b510947b9b4d2a30f
Contents?: true
Size: 867 Bytes
Versions: 1
Compression:
Stored size: 867 Bytes
Contents
module SimpleModelTranslations module InstanceMethods def find_translation_by_locale(locale) translations.detect { |t| t.locale.to_sym == locale } end def find_or_build_translation_by_locale(locale) find_translation_by_locale(locale) || build_translation_for_locale(locale) end def build_translation_for_locale(locale) translations.build(:locale => locale, foreign_object_key => self) end def current_locale_for_translation I18n.locale end def default_locale_for_translation I18n.default_locale end def current_translation find_translation_by_locale(current_locale_for_translation) || find_translation_by_locale(default_locale_for_translation) end private def foreign_object_key self.class.name.underscore.to_sym end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_model_translations-0.2.2 | lib/simple_model_translations/instance_methods.rb |