kaminari-cells icon indicating copy to clipboard operation
kaminari-cells copied to clipboard

Kaminari-cells pulls in ActionView::Helpers::TranslationHelper

Open johnlane opened this issue 8 years ago • 7 comments

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               

johnlane avatar Apr 22 '16 16:04 johnlane

How do you insert your Trailblazer::TranslationHelper?

apotonick avatar May 09 '16 05:05 apotonick

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

johnlane avatar May 09 '16 11:05 johnlane

You could use prepend.... cough

apotonick avatar May 09 '16 20:05 apotonick

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...

johnlane avatar May 10 '16 17:05 johnlane

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?

tjjjwxzq avatar Jan 05 '17 12:01 tjjjwxzq

We should probably just write our own translation "helper" and avoid any Rails mess code?

apotonick avatar Jan 06 '17 00:01 apotonick

Alright :+1: let me see if it's something I can look into

tjjjwxzq avatar Jan 06 '17 03:01 tjjjwxzq