lib/i18n/migrations/migrator.rb in i18n-migrations-2.0.2 vs lib/i18n/migrations/migrator.rb in i18n-migrations-2.0.3
- old
+ new
@@ -70,11 +70,11 @@
end
end
def pull(locale_or_all)
each_locale(locale_or_all) do |locale|
- next if locale.main_locale?
+ # next if locale.main_locale?
backend.pull(locale)
end
end
def push(locale_or_all, force = false)
@@ -102,26 +102,40 @@
locale.validate(data, metadata)
end
end
end
+ private def report_locale_on_error(locale, &block)
+ begin
+ block.call locale
+ rescue Backends::CrowdTranslateError
+ puts "Error\n... while working with #{locale.name}\n#{$!.message}".red
+ # we want a readable error for our users, and the error happened in an external system,
+ # so don't give them a stack trace
+ rescue
+ puts "Error\n... while working with #{locale.name}\n#{$!.message}".red
+ raise
+ end
+ end
+
private def each_locale(name = 'all',
async: true,
- concurrency: config.concurrency)
+ concurrency: config.concurrency,
+ &block)
locale_names = name == 'all' ? all_locale_names : [name]
if async
puts "Using #{concurrency} concurrency"
locale_names.each_slice(concurrency) do |some_locale_names|
threads = some_locale_names.map do |l|
locale = locale_for(l)
- Thread.new { yield locale }
+ Thread.new { report_locale_on_error(locale, &block) }
end
threads.each(&:join)
end
else
locale_names.each do |l|
- yield locale_for(l)
+ report_locale_on_error(locale_for(l), &block)
end
end
end
private def all_locale_names