Sha256: a4d689d49b074c95f3c14ceb1b1bd17de3e6412bf1d0a70833f63a18d48ffcca

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

module Transmating
  module I18n
    extend ActiveSupport::Concern

    included do
      embeds_many :translations, :class_name => "Transmating::Translation",
        :validate => false, :as => :translatable
    end

    def translated(locale)
      self.translations.where(:locale => locale.to_s).first
    end

    def translate(locale, keys = {})
      if translated(locale)
        translated(locale).update_attributes keys
      else
        new_translation = Translation.new keys.merge(:locale => locale.to_s)
        translations << new_translation
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transmating-0.1.0 lib/transmating/i18n.rb