Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

RTeX #l steals I18n #l

#11

The l alias for latex_escape causes grief with projects that are expecting l to be aliased to the localize method of ActionView::Helpers::TranslationHelper.

In the "best-case" scenario, <%= l @date %> in a HTML view simply gives the wrong result. In the worst-case scenario, <%= l @date, :format => @format %> the result is a TemplateError due to the wrong number of arguments.

Ideally, the l alias would just not be used in such situations and be replaced by the intended method (either localize or latex_escape), but sometimes you're working with code written by others that did not take this conflict into consideration.

Reported by David Cato · March 21st, 2009 @ 11:36 PM

State: new
Milestone: none
Assigned to: Bruce Williams Bruce Williams

Activity

  1. David Cato
    David Cato

    After thinking about this a bit further, it seems that the following version of latex_escape might do the trick and allow RTeX to coexist with Rails' I18n code.

    @@@ruby def latex_escape(*args) if Thread.current[:_rendering_rtex]

    RTeX::Document.escape(*args)
    
    

    elsif self.respond_to?(:localize)

    localize(*args)
    
    

    end end

    
    
    At least it does the right thing in my application and tests that were previously failing because the code expected l() to be aliased to localize() are now passing, and the code that expects l() to be aliased to latex\_escape() is still passing.
    

    March 23rd, 2009 @ 12:53 AM

  2. David Cato
    David Cato

    Well, my attempt at including a block of code appears to have failed so I'm attaching it instead.

    March 23rd, 2009 @ 12:57 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.