Sha256: 1363c9cec3e0eb6992e8a8a4fa13efaf6b1d75480cb0dba990dfebd9d9e1fa82

Contents?: true

Size: 446 Bytes

Versions: 20

Compression:

Stored size: 446 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

20 entries across 20 versions & 1 rubygems

Version Path
lolita-translation-0.3.3 lib/lolita-translation/string.rb
lolita-translation-0.2.18 lib/lolita-translation/string.rb
lolita-translation-0.3.2 lib/lolita-translation/string.rb
lolita-translation-0.3.1 lib/lolita-translation/string.rb
lolita-translation-0.3.0 lib/lolita-translation/string.rb
lolita-translation-0.2.9 lib/lolita-translation/string.rb
lolita-translation-0.2.8 lib/lolita-translation/string.rb
lolita-translation-0.2.7 lib/lolita-translation/string.rb
lolita-translation-0.2.6 lib/lolita-translation/string.rb
lolita-translation-0.2.5 lib/lolita-translation/string.rb
lolita-translation-0.2.1 lib/lolita-translation/string.rb
lolita-translation-0.2.0 lib/lolita-translation/string.rb
lolita-translation-0.1.4 lib/lolita-translation/string.rb
lolita-translation-0.1.3 lib/lolita-translation/string.rb
lolita-translation-0.1.2 lib/lolita-translation/string.rb
lolita-translation-0.1.1 lib/lolita-translation/string.rb
lolita-translation-0.1.0 lib/lolita-translation/string.rb
lolita-translation-0.0.3 lib/lolita-translation/string.rb
lolita-translation-0.0.2 lib/lolita-translation/string.rb
lolita-translation-0.0.1 lib/lolita-translation/string.rb