Module: Sequel::Plugins::Localize::InstanceMethods
- Defined in:
- lib/sequel/localize.rb
Instance Method Summary collapse
Instance Method Details
#after_save ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/sequel/localize.rb', line 85 def after_save each_translation do |locale, translation| if translation.pk translation.save else add_translation(translation) end end end |
#default_locale ⇒ Object
95 96 97 |
# File 'lib/sequel/localize.rb', line 95 def default_locale 'de' end |
#translation(locale) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/sequel/localize.rb', line 99 def translation(locale) l = Language[locale] (@_translations ||= {})[locale.to_sym] ||= if pk translations_dataset.where(:language_id => l.id).first end || self.class.translation_class.new(:language_id => l.id) end |
#validate ⇒ Object
107 108 109 110 111 112 |
# File 'lib/sequel/localize.rb', line 107 def validate super each_translation do |locale, translation| errors.add(locale, translation.errors) unless translation.valid? end end |