require "paperclip/globalize3/version"
require "paperclip/globalize3/attachment"

require "globalize"
require "paperclip"

Paperclip.interpolates(:locale) { |attachment, _|
  attachment.instance.send("#{attachment.name}_file_name").translation_metadata[:locale]
}

unless Paperclip::Attachment.instance_methods.include?(:only_process)
  Paperclip::Attachment.send(:include, Paperclip::Globalize3::Attachment::Compatibility::Paperclip33)
end

Paperclip::Attachment.send(:include, Paperclip::Globalize3::Attachment)

require "paperclip/globalize3/version"
require "paperclip/globalize3/attachment"

require "globalize"
require "paperclip"

Paperclip.interpolates(:locale) { |attachment, _|
  if attachment.instance.respond_to?(:translation_metadata)
    attachment.instance.send("#{attachment.name}_file_name").translation_metadata[:locale].to_s
  else
    Globalize.locale.to_s
  end
}

unless Paperclip::Attachment.instance_methods.include?(:only_process)
  Paperclip::Attachment.send(:include, Paperclip::Globalize3::Attachment::Compatibility::Paperclip33)
end

Paperclip::Attachment.send(:include, Paperclip::Globalize3::Attachment)

Test for translation_metadata before using it.
Test for translation_metadata before using it.
