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

Update TimeFormatter to include localized Strings #1106

Merged
merged 1 commit into from
Jul 16, 2018

Conversation

danesfeder
Copy link
Contributor

Closes #1097

We are currently using hard-coded constants for arrival time formatting. This PR replaces them with String resources, which have also already been pushed to Transifex.

Noting that this PR does not actually add the necessary translations but it does set up the code to be ready for them once we pull them from Transifex.

@danesfeder danesfeder added this to the 0.16.0 milestone Jul 11, 2018
@danesfeder danesfeder self-assigned this Jul 11, 2018
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Some minor comments. Other than that this looks 💯
Thanks @danesfeder 🙏

@@ -492,6 +491,11 @@ private void sendFeedbackEvent(FeedbackEvent feedbackEvent) {
feedbackEvent.getFeedbackType(), feedbackEvent.getScreenshot(), feedbackEvent.getFeedbackSource());
}

private long dateDiff(Date date1, Date date2, TimeUnit timeUnit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rename date1 and date2 into something more semantic?

return dateDiff(new Date(lastCheckedLocation.getTime()), new Date(location.getTime()), TimeUnit.SECONDS);
}

private long dateDiff(Date date1, Date date2, TimeUnit timeUnit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here ☝️

@@ -8,4 +8,12 @@
<string name="miles">mi</string>
<string name="feet">ft</string>
<string name="eta_format">%s ETA</string>

<!-- Time formatting -->
<string name="day">day</string>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use quantity string (plurals) instead of having multiple "day" strings?

@danesfeder
Copy link
Contributor Author

@Guardiola31337 this is updated and ready for another round of 👀 - do you mind checking my usage of plurals? That's a great suggestion, btw! Want to make sure I got it right.

Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

@danesfeder

do you mind checking my usage of plurals?

Looks 💯 to me.

Minor comment not blocking the PR.

Thanks for dealing with this one 🙏

if (days != 0) {
String dayFormat = days > 1 ? DAYS : DAY;
String dayString = String.format(" %s ", resources.getQuantityString(R.plurals.numberOfDays, (int) days));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we extract " %s " magic number?

@danesfeder danesfeder merged commit 04aec2d into master Jul 16, 2018
@danesfeder danesfeder deleted the dan-localize-bottomsheet branch July 16, 2018 14:16
@Guardiola31337
Copy link
Contributor

@danesfeder do we need to update/do something in Transifex for supporting latest changes (especially plurals)? Forgot to ask before merging 🤦‍♂️ Sorry!

@danesfeder
Copy link
Contributor Author

@Guardiola31337 yeah we should push the update strings.xml to Transifex - I'm wondering if the plurals usage will throw off Transifex, but we will have to see

@danesfeder danesfeder mentioned this pull request Jul 20, 2018
11 tasks
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.

2 participants