kaminari-cells
kaminari-cells copied to clipboard
Kaminari-cells pulls in ActionView::Helpers::TranslationHelper
I was having problems with translations in a cell after adding Kaminari to it.
I found that ActionView::Helpers::TranslationHelper
was taking precedence over my Trailblazer::Translations
. I tracked this down to kaminari-cells.rb.
#11 include ActionView::Helpers::TranslationHelper
Does this gem really need a hard dependency on ActionView::Helpers::TranslationHelper
?
As a work-around, I have put a method in the classes where I have Kaminari::Cells
:
def t(*args)
Trailblazer::Translation.t(*args)
end
How do you insert your Trailblazer::TranslationHelper
?
Currently I am including it into Cell::Concept
in an initializer:
Cell::Concept.class_eval do
include Cell::Erb
include Trailblazer::Translation
extend Trailblazer::Translation
... other stuff ...
end
You could use prepend
.... cough
The effect of prepend
is to move Trailblazer::Translation
up, but not up far enough...
Kaminari::Helpers::CellsHelper, Kaminari::Helpers::CellsHelper,
Cell::ViewModel::Partial, Cell::ViewModel::Partial,
ActionView::Helpers::TranslationHelper, ActionView::Helpers::TranslationHelper,
Kaminari::ActionViewExtension, Kaminari::ActionViewExtension,
Kaminari::Cells, Kaminari::Cells,
SimpleForm::ActionViewExtensions::FormHelper, SimpleForm::ActionViewExtensions::FormHelper,
ActionView::Helpers::FormOptionsHelper, ActionView::Helpers::FormOptionsHelper,
ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::JavaScriptHelper,
> Trailblazer::Translation,
Cell::Concept, Cell::Concept,
ActionView::RecordIdentifier, ActionView::RecordIdentifier,
ActionView::ModelNaming, ActionView::ModelNaming,
Trailblazer::Translation, <
Cell::Erb, Cell::Erb,
I've only quickly tried this, I'll give it some more attention tomorrow...
This blows things up with cells-slim
because ActionView::Helpers::TranslationHelper
helpfully pulls its friend CaptureHelper
along, which overrides the with_output_buffer
method from Cell::Slim
. Do you see a way of fixing this, or, can I open a PR to add a caveat and workaround to the README?
We should probably just write our own translation "helper" and avoid any Rails mess code?
Alright :+1: let me see if it's something I can look into