-
-
Notifications
You must be signed in to change notification settings - Fork 410
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
Customise hash deep symbolize keys #444
Conversation
This will ensure compatibility with old I18n (1.1.0) (see also issue #443) and what is now expected as of 1.2.0 (see #422) I have switched this Hash class method monkey patching to use refinements, because it will keep the method overriding contained to the select places of the I18n gem where it is used.
For this PR to be merged, i18n will need to drop support for Ruby 2.0. Given that this Ruby version was EOL'd on 2016-02-24, I think that it will be acceptable to do that. I do realise that this will mean that any i18n release after this point will not be compatible with any I'm happy to make this sacrifice also. |
Let's look at some examples across
1.1.1
1.2.0
|
See #445 for an extra test case clarifying the API discussed here, as well as a PR proposal that would support all of the various use-cases in a slightly more backwards-compatible fashion. |
Support integer keys with string lookup
Given that this PR both fixes this regression and changes the minimum required Ruby version, I will be releasing it as 1.3.0. |
@radar Having just encountered this regression in production, can I please ask for this to be merged asap? |
I merged this PR manually to master because I was time-limited last night and Travis was taking too long to even start the build. Here is the commit: 949dc64. If you’re still seeing an issue definitely on 1.3.0, please open a new issue with steps to reproduce. |
Due to new behaviour introduced in #422, numbers are now treated differently. There are people using this new behaviour in the wild (see ice-cube-ruby/ice_cube#462), and simultaneously people who want the old behaviour #443.
Both are sensible.
I have now reverted some of the changes in #422 and have made my own attempt at the problem here by changing how
deep_symbolize_keys
works. It checks the type of the key and from that determines if it is "symbolizable" or not, rather than blindly rescuing from any thrown exceptions. The only two types that are "symbolizable" areString
and the parent class of all numbers:Numeric
. I think this covers all use-cases.Rather than releasing I18n 1.2.1 with this fix contained, I want to give @wjordan, and @adamniedzielski (and anyone else) until 8pm Thursday night Australian Eastern Time to test this change on their applications.
You can do so by adding this line to your
Gemfile
:If there are no reported regressions by 8pm Thursday night Australian Eastern Time, I will be merging this patch to master and then immediately releasing 1.2.1.
Thanks for your patience while we try to resolve this regression.