Fixing {{model}} placeholders in Rails 2.3 when Rails 3 is installed

This was causing me all kinds of grief. I am running Rails 2.3 and Rails 3 apps on the same server and on installing Rails 3, the Rails 2.3 apps started displaying {{model}} and similar strings in views.
It turns out that Rails 3 uses i18n version 0.5.0 and with this version as far as I can see, the placeholder text in translations follow the %{text} format instead of the {{text}} format in 0.4.2 which Rails 2.3 was using. The only way I found to fix this was to declare the specific i18n version before the Rails gem gets required in the “load_rails_gem” method of “config/boot.rb” in my Rails 2.3 apps:

def load_rails_gem
  gem 'i18n', '0.4.2' # Add this line
  if version...

Doing this specifies that we want i18n 0.4.2 exactly, whereas Rails 2.3 specifies version “>= 0.1.3” which would obviously includes “0.5.0”.
In running Rails 2.3 and Rails 3 apps side by side, I also ran into this problem and overcame it with the fixes by “bct” and “ronin-95281” in the comments… apparently Rails Core won’t fix this.
If anyone else has a cleaner fix for this I would love to hear about it.

Join the conversation


  1. Yes, I’ve used bundler too, as this also works for other Sinatra/Rack apps. I tend to pack gems in vendor/cache (I think bundler package does this)
    The issue I think originally stems from the fact that i18n has switched it’s interpolation format to match that of Ruby 1.9. (There’s a few other places in Rails where things have been migrating towards Ruby 1.9, though in most cases ActiveSupport has done a good job of abstracting this away).
    Have you been using Ruby 1.9 much? (It’s worth using in development mode now, it’ll take away a lot of pain of getting into situations like later from my experience, not ot mention the speed increase)

  2. @christoph & @jase Thanks, bundler is definitely a cleaner option, the problem I have is that the problem exists locally also so I will just be bundling the problem to the server.
    @jase I’m using RVM locally so I occasionally switch to 1.9 to check everything still works for when it comes to upgrading the server… that’s the next job.

Leave a comment

Your email address will not be published. Required fields are marked *