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

🐛 Ensure knapsack translations are first choice #63

Merged
merged 1 commit into from
Oct 5, 2023
Merged
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
7 changes: 0 additions & 7 deletions app/controllers/catalog_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@
config.add_facet_field 'part_of_sim', limit: 5
config.add_facet_field 'refereed_sim', limit: 5

# Prior to this change, the applications specific translations were not loaded.
# Dogbiscuits were assuming the translations were already loaded.
Rails.root.glob("config/locales/*.yml").each do |path|
I18n.load_path << path.to_s
end
I18n.backend.reload!

# Clobber all existing index and show fields that come from Hyku base but skip
# the non-DogBiscuit keys that Adventist had already configured in a pre-Knapsack state
# see: https://github.com/scientist-softserv/adventist-dl/blob/97bd05946345926b2b6c706bd90e183a9d78e8ef/app/controllers/catalog_controller.rb#L38-L40
Expand Down
9 changes: 6 additions & 3 deletions lib/hyku_knapsack/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ class Engine < ::Rails::Engine
end
::ApplicationController.send :helper, HykuKnapsack::Engine.helpers

# Moves the Dog Biscuits locales to the end of the load path
Dir[Pathname.new(my_engine_root).join('config', 'locales', '**', 'dog_biscuits.*.yml')].each do |path|
I18n.load_path.push(path)
# Ensure that all knapsack locales are the "first choice" of keys.
HykuKnapsack::Engine.root.glob('config/locales/**/*.*').each do |path|
I18n.load_path.push(path.to_s)
end

# When we add translation files, we need to load them as well.
I18n.backend.reload!
end
end
end
12 changes: 12 additions & 0 deletions spec/hyku_knapsack/engine_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe HykuKnapsack::Engine do
describe 'I18n' do
it 'has "en.dog_biscuits.fields.date_issued" key' do
expect(I18n.t('dog_biscuits.fields.date_issued')).not_to start_with("Translation missing:")
expect(I18n.t('dog_biscuits.fields.date_issued')).to eq("Date")
end
end
end
Loading