Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load all locales from config.i18n.available_locales #1521

Merged
merged 1 commit into from
Dec 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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