#11 new
David Cato

RTeX #l steals I18n #l

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

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.

Comments and changes to this ticket

  • David Cato

    David Cato March 23rd, 2009 @ 12:53 AM

    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]


    elsif self.respond_to?(:localize)


    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.
  • David Cato

    David Cato March 23rd, 2009 @ 12:57 AM

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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

RTeX is a Ruby library (and web framework plugin) used to generate PDF documents on-the-fly using the LaTeX typesetting system.

People watching this ticket