Skip to content

Commit

Permalink
Merge pull request #1521 from printercu/patch-1
Browse files Browse the repository at this point in the history
Load all locales from config.i18n.available_locales
  • Loading branch information
bensie committed Dec 10, 2014
2 parents d2d1746 + e5390c0 commit 550af9d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/carrierwave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ def tmp_path

module CarrierWave
class Railtie < Rails::Railtie
initializer "carrierwave.setup_paths" do
initializer "carrierwave.setup_paths" do |app|
CarrierWave.root = Rails.root.join(Rails.public_path).to_s
CarrierWave.base_path = ENV['RAILS_RELATIVE_URL_ROOT']

pattern = CarrierWave::Railtie.locales_pattern_from app.config.i18n.available_locales

files = Dir[File.join(File.dirname(__FILE__), 'carrierwave', 'locale', "#{pattern}.yml")]
# Loads the Carrierwave locale files before the Rails application locales
# letting the Rails application overrite the carrierwave locale defaults
I18n.load_path = files.concat I18n.load_path
end

initializer "carrierwave.active_record" do
Expand All @@ -50,11 +57,11 @@ class Railtie < Rails::Railtie
end
end

##
# Loads the Carrierwave locale files before the Rails application locales
# letting the Rails application overrite the carrierwave locale defaults
config.before_configuration do
I18n.load_path << File.join(File.dirname(__FILE__), "carrierwave", "locale", 'en.yml')
protected

def self.locales_pattern_from(args)
array = Array(args || [])
array.blank? ? '*' : "{#{array.join ','}}"
end
end
end
Expand Down

0 comments on commit 550af9d

Please sign in to comment.