Sha256: ba1c439c962b55d2d300fb20b6c9495dc5e641f612c9a0e126451da9c4209a89

Contents?: true

Size: 464 Bytes

Versions: 1

Compression:

Stored size: 464 Bytes

Contents

class String
  attr_accessor :origin_model, :origin_name
  def set_origins obj, name
    self.origin_model = obj
    self.origin_name = name
    self
  end
  # forces given locale
  # I18n.locale = :lv
  # a = Article.find 18
  # a.title
  # => "LV title"
  # a.title.in(:en)
  # => "EN title"
  def in locale
    return self unless self.origin_model
    translation = self.origin_model.in(locale) and translation.send(self.origin_name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lolita-translation-0.0.4 lib/lolita-translation/string.rb