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

Relative time is parsed differently between languages #277

Open
mingan opened this issue Jun 26, 2019 · 4 comments
Open

Relative time is parsed differently between languages #277

mingan opened this issue Jun 26, 2019 · 4 comments

Comments

@mingan
Copy link

mingan commented Jun 26, 2019

Most supported languages (146/156) allow to parse strings like -1 year in English (our use case is a date range picker with some predefined ranges). Some languages, however, have the regexps localized and thus fail with the input in English, e.g. Romanian bc2c7a6

It's unclear which behaviour is correct. Given that these regexps live in a hash alongside regexps which need to be localized it makes sense to localize them as well. On the other hand, vast majority parses this input only in English.

In our case, we need to parse the English version in every language and had to override the localized regexps.

@abritinthebay
Copy link
Owner

That behavior is correct, or at least intended, however if you know the input is going to be English you could always switch the language to that & turn it back afterwards?

Going to close this as it’s intended behavior but I hope that gives you a path to a smoother workaround...

@mingan
Copy link
Author

mingan commented Jun 27, 2019

Thank you for the tip.

An uncharitable reading of your comment would be the intended behaviour is chaos and confusion. I assume you don't mean it but closing the issue seems premature. If the intended behaviour is to parse localized strings, 146/156 locales in the library are incorrect - that seems like a serious bug to me. Sure, it's unfeasible to fix so many locales at once but at least documenting the behaviour and warning about the low penetration might save others the pain of figuring out for themselves.

@abritinthebay
Copy link
Owner

If you feel you can fix the regex for Romanian to your satisfaction a PR is welcome.

@mingan
Copy link
Author

mingan commented Jul 4, 2019

I'm not a Romanian speaker but I added Czech.

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