Skip to content

Humanize distance intl#358

Merged
binh-dam-ibigroup merged 2 commits intoopentripplanner:masterfrom
ibi-group:humanize-distance-intl
Mar 16, 2022
Merged

Humanize distance intl#358
binh-dam-ibigroup merged 2 commits intoopentripplanner:masterfrom
ibi-group:humanize-distance-intl

Conversation

@binh-dam-ibigroup
Copy link
Copy Markdown
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup commented Mar 3, 2022

Requires #355 (for an updated correct dependency version). Update: #355 is now merged in master.

This PR adds i18n support to the humanize-distance package while maintaining backwards compatibility (use of react-intl remains optional with this package).

@binh-dam-ibigroup binh-dam-ibigroup added the BLOCKERS Blockers exist outside of otp-ui (e.g., backend, service, etc...) label Mar 3, 2022
@binh-dam-ibigroup binh-dam-ibigroup changed the base branch from master to bug/location-field-transit March 15, 2022 17:56
@binh-dam-ibigroup binh-dam-ibigroup changed the base branch from bug/location-field-transit to master March 15, 2022 17:57
@binh-dam-ibigroup binh-dam-ibigroup removed the BLOCKERS Blockers exist outside of otp-ui (e.g., backend, service, etc...) label Mar 15, 2022
@binh-dam-ibigroup
Copy link
Copy Markdown
Collaborator Author

With #355 merged, this PR is now ready for review @philip-cline cc: @fpurcell.

Copy link
Copy Markdown
Collaborator

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than I expected but looks good to me and works well in my (limited) testing!

Comment thread packages/humanize-distance/src/index.ts Outdated
Comment on lines +23 to +25
unit = "mile";
unitIfNoIntl = abbreviate ? "mi" : "miles";
value = roundToOneDecimalPlace(feet / 5280);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably clean this up a bit if we used these values as the default case for those lets

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, addressed in 9dcf6e7.

Comment thread packages/humanize-distance/src/index.ts Outdated
Comment on lines 51 to 55
} else {
unit = "meter";
shortUnit = "m";
value = Math.round(meters);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably clean this up a bit if we used these values as the default case for those lets

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 9dcf6e7.

let unitIfNoIntl;

if (feet < 528) {
unit = "foot";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in thinking that formatMessage will re-write foot?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will also use the correct decimal separator.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh cool!

@miles-grant-ibigroup miles-grant-ibigroup removed their assignment Mar 16, 2022
@binh-dam-ibigroup binh-dam-ibigroup merged commit 7cec521 into opentripplanner:master Mar 16, 2022
@binh-dam-ibigroup binh-dam-ibigroup deleted the humanize-distance-intl branch March 16, 2022 22:27
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

Successfully merging this pull request may close these issues.

4 participants