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

Fix #3841: Combine time and quantity plurals #5153

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ private static String getTimeAgo(View view, long lastVisitedTimestamp) {
} else if (timeDifferenceMillis < TimeUnit.MINUTES.toMillis(50)) {
return getPluralString(
resourceHandler,
R.plurals.minutes,
R.plurals.minutes_ago,
(int) TimeUnit.MILLISECONDS.toMinutes(timeDifferenceMillis)
);
} else if (timeDifferenceMillis < TimeUnit.DAYS.toMillis(1)) {
return getPluralString(
resourceHandler,
R.plurals.hours,
R.plurals.hours_ago,
(int) TimeUnit.MILLISECONDS.toHours(timeDifferenceMillis)
);
} else if (timeDifferenceMillis < TimeUnit.DAYS.toMillis(2)) {
return resourceHandler.getStringInLocale(R.string.yesterday);
}
return getPluralString(
resourceHandler,
R.plurals.days,
R.plurals.days_ago,
(int) TimeUnit.MILLISECONDS.toDays(timeDifferenceMillis)
);
}
Expand All @@ -107,13 +107,9 @@ private static String getPluralString(
@PluralsRes int pluralsResId,
int count
) {
// TODO(#3841): Combine these strings together.
return resourceHandler.getStringInLocaleWithWrapping(
R.string.time_ago,
resourceHandler.getQuantityStringInLocaleWithWrapping(
return resourceHandler.getQuantityStringInLocaleWithWrapping(
pluralsResId, count, String.valueOf(count)
)
);
);
}

private static long ensureTimestampIsInMilliseconds(long lastVisitedTimestamp) {
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@
<!-- TextViewBindingAdapters -->
<string name="just_now">just now</string>
<string name="last_logged_in_recently">recently</string>
<string name="time_ago">%s ago</string>
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
<string name="yesterday">yesterday</string>
<string name="return_to_topic">Return to topic</string>
<string name="return_to_lesson">Return to lesson</string>
Expand All @@ -481,17 +480,18 @@
<string name="up_button_disabled">Up</string>
<string name="down_button_disabled">Down</string>
<string name="profile_last_visited">%s %s</string>
<plurals name="minutes">
<item quantity="one">a minute</item>
<item quantity="other">%s minutes</item>
<plurals name="minutes_ago">
<item quantity="zero">0 minutes ago</item>
<item quantity="one">a minute ago</item>
<item quantity="other">%s minutes ago</item>
</plurals>
<plurals name="hours">
<item quantity="one">an hour</item>
<item quantity="other">%s hours</item>
<plurals name="hours_ago">
<item quantity="one">an hour ago</item>
<item quantity="other">%s hours ago</item>
</plurals>
<plurals name="days">
<item quantity="one">a day</item>
<item quantity="other">%s days</item>
<plurals name="days_ago">
<item quantity="one">a day ago</item>
<item quantity="other">%s days ago</item>
</plurals>
<!-- ViewTags -->
<string name="topic_revision_recyclerview_tag">topic_revision_recyclerview_tag</string>
Expand Down
Loading