-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix: support distance display in metric units #736
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for contributing! And thanks so much for your kind words about the project. Your prop-based solution is well-implemented, but I think we're hoping to use our localization library to implement this feature
Hi @miles-grant-ibigroup, sorry I didn't know about your localization library. Should I close this PR, do you want me to check that localization library? Let me know if I can be of any help. Thanks |
You can keep this PR open! We use I hope this is helpful. This is on our backlog to do ourselves, but we probably won't get to it soon. |
Hi there. It seems that only three countries still use the imperial units so I can hardcode those countries and use react-intl. If you are not in a hurry I'd like to work on this issue. |
That sounds great! Please do it's much appreciated. I'll be here to review when you're ready :) |
Great @miles-grant-ibigroup. How about using this?
|
Hi @miles-grant-ibigroup I've modified the PR adding a function to check if according to react-intl locale we have to use metric or imperial units. Now fewer files are modified. Here are two screenshots showing the changes of locale in action and how the units are changed. Also, hope you don't mind, as I'm a Spaniard I've changed some entries for the itinerary-body es.yaml Please let me know if you want me to change anything Cheers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fantastic contribution thank you so much! I really appreciate your translation updates as well.
I have one review comment that would clean up the code. Once that's done I'll assign to a second reviewer! We do 2 reviews per PR -- once the second reviewer approves we will merge!
coreUtils.metricUnits.areMetricUnitsUsed(intl.locale), | ||
intl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to refactor humanizeDistanceString
to use the intl
object it gets anyway to avoid having to import coreUtils
everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say don't remove the manual override (for backwards compatibility) but instead use it as an override -- a way to force metric even if the locale isn't metric
As for the failing unit tests running |
Thanks @miles-grant-ibigroup I'll prepare the changes |
Hi there, the following PR deals with issue #116
I've added a useMetricUnits props to the affected components reported in the issue:
This prop is optional with default value false which means that imperial units will be used. If useMetricUnits is set, metric units will be used instead.
I've also added some stories to test useMetricUnits in action:
As this is my first ever contribution to this project so I hope this first contribution is useful. Please don't hesitate to tell me what I should improve or change for my future contributions.
This an awesome project, thank's a lot for your effort and the quality of the code. It's great that you've published it as an open source project, hopefully I'll try to upload more contributions soon.
Cheers!