This project is archived and is in readonly mode.

#4371 ✓resolved
Mario

I18n.translate strange behavior with the << operator

Reported by Mario | April 12th, 2010 @ 04:56 PM

Run script/console in a Rails application:

x = I18n.translate 'foo' => "Foo text"

x << ' more text added on the fly' => "Foo text more text added on the fly"

I18n.translate 'foo' # OhMy!! the added text is now in the translation cache! => "Teixo more text added on the fly"

This not occurs if use the += operator (x += 'some text'), but the problem is that this behavior is unespected, and quite hard to detect.
One solution may be to clone the returned String in the I18n.translate implementation.

Comments and changes to this ticket

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages