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 with leading zero keys #456

Closed
oleksii-leonov opened this issue Jan 6, 2019 · 2 comments
Closed

Regression with leading zero keys #456

oleksii-leonov opened this issue Jan 6, 2019 · 2 comments

Comments

@oleksii-leonov
Copy link
Contributor

What I tried to do

With next localization keys:

en:
  test_data:
    '000': 'Value 000'
    '001': 'Value 001'
    '002': 'Value 002'
    '111': 'Value 111'

I18n version 1.1.1 it works fine:

> I18n.t('test_data.001')
=> "Value 001"

I18n version 1.4.0 didn't work:

> I18n.t('test_data.001')
=> "translation missing: en.test_data.1"

What I expected to happen

Behavior should be consistent with version 1.1.1.

What actually happened

Behavior changed.

Versions of i18n, rails, and anything else you think is necessary

Changes was introduced in 38732a6

k.to_i


I believe, i18n should't try convert keys to number if key starts with 0.

So, regexp:

when /\A[-+]?\d+\z/ # integer

should be changed with: \A[-+]?[1-9]\d*\z.

This way strings like 12345 would be converted to numbers, but strings like 0001 stay untouched.

@radar
Copy link
Collaborator

radar commented Jan 6, 2019

Thanks for letting us know about it. It seems like you know the solution already. Please submit a PR to fix it.

oleksii-leonov added a commit to oleksii-leonov/i18n that referenced this issue Jan 6, 2019
@oleksii-leonov
Copy link
Contributor Author

@radar
Done in #457.

@radar radar closed this as completed in #457 Jan 6, 2019
Envek added a commit to Envek/i18n that referenced this issue Feb 26, 2019
They should be treated consistently with other integer-like keys.

See [ruby-i18n#456] and [ruby-i18n#457] for reference.

[ruby-i18n#456]: ruby-i18n#456
[ruby-i18n#457]: ruby-i18n#457
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

2 participants