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

Use driver locale files #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions lib/rails_drivers/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def add_every_driver_to_rails_paths
rails_config.autoload_paths += [
"#{rails_config.root}/#{driver}/lib"
]

# Load driver locales
locale_path = "#{rails_config.root}/#{driver}/config/locales"
config.i18n.load_path += [Dir["#{locale_path}/**/*.{rb,yml}"]] if Dir.exist?(locale_path)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_drivers/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RailsDrivers
VERSION = '1.2.0'
VERSION = '1.3.0'
end
18 changes: 18 additions & 0 deletions spec/drivers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,22 @@ def make_rake_task(namespace)
expect { run_command 'rake driver:store:dummy_nested:run' }.to_not raise_error
end
end

context 'with locales in a driver' do
let(:en_locale) do
<<-YAML
---
en:
test_key: 'value from driver!'
YAML
end

before do
create_file 'drivers/store/config/locales/en.yml', en_locale
end

it 'properly loads the driver locale files' do
expect(run_ruby('puts I18n.with_locale(:en) { I18n.t("test_key") }')).to eq "value from driver!\n"
end
end
end