New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The TranslatedString#to_s now returns nil some cases #136
Comments
TranslatedString#to_s
now returns nil
some cases
BTW, the class C < String
end
p C.new("test").split("t").map{ |x| [x.class, x] } Other string methods really seem to share this class cloning behaviour, such as |
BTW, testing the mentioned commit a bit further, it also seems that the conversion of value to string added to the beginning of |
And while we are at it, the change at translation.rb:96 from |
Thanks for really good investigation. I will look closer on this week. |
Hello, sorry for the bump, but is there any chance to get this fixed? Alternatively, I can try to create a patch myself. Just one question - do you remember what was the idea behind introducing |
Yeap, PR will be very welcome |
OK, I will have a look. Is support for 2.2+ enough or shall I aim for 2.1 as well? |
2.1 support will be good, because I need a major release to drop 2.1 support. |
OK, the PR is ready in #147. |
The commit 2e54394 introduced some bugs.
First of all, I believe
TranslatedString#to_s
should check if the@value
responds tohtml_safe
, not self.More important thing however is that now
to_s
doesn't work at all in some cases. Before, code like this was working fine for translated strings:Now it fails (with undefined method
encoding
fornil:NilClass
error). The reason is thatsplit
creates array ofTranslatedString
s, none of which however have the@value
set. Cloning the class of the actual string itself seems to be a feature ofsplit
, but it obviously causes mismatch between the value of the string itself and the@value
variable, which is now lacking (not to mention the lack of other instance variables, but it's not much of an problem for me).I believe other String operations might suffer from the same problem, so it might be best to drop the
@value
idea entirely and base the value of the string solely on the string itself.The text was updated successfully, but these errors were encountered: