This project is archived and is in readonly mode.
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
-
Mario April 12th, 2010 @ 05:03 PM
Sorry, the previous post is not correctly formatted.
Repeat code:x = I18n.translate :foo #=> "Foo Text" x << ' plus more text added on the fly' #=> "Foo Text plus more text added on the fly" # OhMy!! The added text is now in the translation cache! I18n.translate :foo #=> "Foo Text plus more text added on the fly"
Using the << operator, in each request the same text is appended, and is hard to discover the reason.
-
thedarkone April 12th, 2010 @ 11:04 PM
This commit to the
I18n
library probably fixes your problem: http://github.com/svenfuchs/i18n/commit/0ca77036fccec252a546db51d29... -
Santiago Pastorino April 12th, 2010 @ 11:21 PM
- State changed from new to resolved
Yes and it's an I18n thing
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>