Skip to content
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

Regression(?) in v1.3.0, when used with rails-i18n #449

Closed
tom-lord opened this issue Dec 20, 2018 · 7 comments
Closed

Regression(?) in v1.3.0, when used with rails-i18n #449

tom-lord opened this issue Dec 20, 2018 · 7 comments

Comments

@tom-lord
Copy link
Contributor

tom-lord commented Dec 20, 2018

What I tried to do

"Composite" translations, where a hash is defined within the translation itself, have changed behaviour in v1.2.0 and v1.3.0, when this gem is used in a Rails application.

What I expected to happen/actually happened/versions

Here is a repo I have created demonstrating the behavioural changes:

https://github.com/tom-lord/i18n_regression

In particular, note that we have now stringified they keys of nested hashes (the last line says "hello", not :hello).

Is the new behaviour desired? Maybe.

Unlike before, v1.3.0 of this library's behaves the same way with and without Rails.

However, it's an undocumented change, which caught me off-guard. If this behaviour is expected, can we please add a regression test and ideally documentation?

@tom-lord tom-lord changed the title Regression in v1.2.0 and v1.3.0, when used in Rails Regression(?) in v1.3.0, when used with rails-i18n Dec 20, 2018
@tom-lord
Copy link
Contributor Author

Relates to:
#422
#443
#444
#445

@radar
Copy link
Collaborator

radar commented Dec 20, 2018

Thank you for reporting this. My understanding of the code in core_ext/hash means that this hello key should be symbolised as well, due to the nature of deep_symbolize_keys. If it is not, then I would consider that a bug.

A patch with at least a regression test would be appreciated. Similarly to #447, I will not have time to investigate this deeply until after Jan 2.

@PikachuEXE
Copy link
Contributor

@tom-lord
Please take a look at #450 for possible fix

@radar radar reopened this Dec 21, 2018
@PikachuEXE
Copy link
Contributor

reopened?

@radar
Copy link
Collaborator

radar commented Dec 21, 2018

possible fix

Not 100% confirmed by @tom-lord

I’m just being cautious after the #444 debacle.

@tom-lord
Copy link
Contributor Author

tom-lord commented Dec 21, 2018

@PikachuEXE @radar Thanks for the quick response/feedback/fix.

I'm happy with #450 as a fix for the issue. I think the new behaviour is best, for the majority of users.

Focusing on the "composite keys" situation, to summarise what's changed now:

v1.1.1:

  • With rails: Keys are symbols, unless integer/boolean.
  • Without rails: Keys are strings, unless integer/boolean.

v1.2.0:

  • With rails: Keys are symbols, (always).
  • Without rails: Keys are strings, unless integer/boolean.

v1.3.0:

  • With rails: Keys are strings, unless integer/boolean.
  • Without rails: Keys are strings, unless integer/boolean.

master [EDIT - now released in v1.4.0]:

  • With rails: Keys are symbols, unless integer/boolean.
  • Without rails: Keys are symbols, unless integer/boolean.

Both v1.3.0 and master seem valid to me; but both are a change in behaviour. So either way, a little documentation on the matter (even just a mention in the CHANGELOG) would be very helpful.

In my opinion, making keys symbols-unless-integer/boolean (the current master version) is best, in terms of consistency and backwards compatibility. In future, perhaps consider dropping this weird integer/boolean edge case, and just making keys always symbols - but that's a breaking change.

yahonda added a commit to yahonda/oracle-enhanced that referenced this issue Dec 22, 2018
yahonda added a commit to yahonda/oracle-enhanced that referenced this issue Dec 23, 2018
yahonda added a commit to yahonda/oracle-enhanced that referenced this issue Dec 24, 2018
yahonda added a commit to yahonda/oracle-enhanced that referenced this issue Dec 26, 2018
@radar
Copy link
Collaborator

radar commented Jan 1, 2019

Thank you for your confirmation @tom-lord. I agree that symbolising everything would make the API at least consistent, and also agree that it's a breaking change; something that should go into a new major release (i.e. 2.x) -- which is a long way off at this point in time.

@radar radar closed this as completed Jan 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants