Class: Translatomatic::Translation::Sharer
- Inherits:
-
Object
- Object
- Translatomatic::Translation::Sharer
- Defined in:
- lib/translatomatic/translation/sharer.rb
Overview
Share translations with providers
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Sharer
constructor
A new instance of Sharer.
- #share(collection) ⇒ void
Constructor Details
#initialize(options = {}) ⇒ Sharer
Returns a new instance of Sharer.
5 6 7 |
# File 'lib/translatomatic/translation/sharer.rb', line 5 def initialize( = {}) @options = end |
Instance Method Details
#share(collection) ⇒ void
This method returns an undefined value.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/translatomatic/translation/sharer.rb', line 12 def share(collection) return if collection.empty? tmx = Translatomatic::TMX::Document.from_collection(collection) available = Translatomatic::Provider.available(@options) available.each do |provider| if provider.respond_to?(:upload) log.info(t('sharer.uploading_tmx', name: provider.name)) provider.upload(tmx) end end ActiveRecord::Base.transaction do db_texts.each do |text| text.update(shared: true) if text.translated? end end end |