Do not use plural form for 1 second/minute/hour/day/month/year

Bug: issue 2150
Change-Id: I016484916b54789edace67cf3ed17f21580ef2c3
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-09-30 17:45:50 +02:00
parent 4e5bdee59a
commit 2a97106487
3 changed files with 58 additions and 7 deletions

View File

@@ -51,32 +51,62 @@ public class RelativeDateFormatter {
// seconds
if (ageMillis < upperLimit(MINUTE_IN_MILLIS)) {
return Util.M.secondsAgo(round(ageMillis, SECOND_IN_MILLIS));
long seconds = round(ageMillis, SECOND_IN_MILLIS);
if (seconds == 1) {
return Util.C.oneSecondAgo();
} else {
return Util.M.secondsAgo(seconds);
}
}
// minutes
if (ageMillis < upperLimit(HOUR_IN_MILLIS)) {
return Util.M.minutesAgo(round(ageMillis, MINUTE_IN_MILLIS));
long minutes = round(ageMillis, MINUTE_IN_MILLIS);
if (minutes == 1) {
return Util.C.oneMinuteAgo();
} else {
return Util.M.minutesAgo(minutes);
}
}
// hours
if (ageMillis < upperLimit(DAY_IN_MILLIS)) {
return Util.M.hoursAgo(round(ageMillis, HOUR_IN_MILLIS));
long hours = round(ageMillis, HOUR_IN_MILLIS);
if (hours == 1) {
return Util.C.oneHourAgo();
} else {
return Util.M.hoursAgo(hours);
}
}
// up to 14 days use days
if (ageMillis < 14 * DAY_IN_MILLIS) {
return Util.M.daysAgo(round(ageMillis, DAY_IN_MILLIS));
long days = round(ageMillis, DAY_IN_MILLIS);
if (days == 1) {
return Util.C.oneDayAgo();
} else {
return Util.M.daysAgo(days);
}
}
// up to 10 weeks use weeks
if (ageMillis < 10 * WEEK_IN_MILLIS) {
return Util.M.weeksAgo(round(ageMillis, WEEK_IN_MILLIS));
long weeks = round(ageMillis, WEEK_IN_MILLIS);
if (weeks == 1) {
return Util.C.oneWeekAgo();
} else {
return Util.M.weeksAgo(weeks);
}
}
// months
if (ageMillis < YEAR_IN_MILLIS) {
return Util.M.monthsAgo(round(ageMillis, MONTH_IN_MILLIS));
long months = round(ageMillis, MONTH_IN_MILLIS);
if (months == 1) {
return Util.C.oneMonthAgo();
} else {
return Util.M.monthsAgo(months);
}
}
// up to 5 years use "year, months" rounded to months
@@ -94,7 +124,12 @@ public class RelativeDateFormatter {
}
// years
return Util.M.yearsAgo(round(ageMillis, YEAR_IN_MILLIS));
long years = round(ageMillis, YEAR_IN_MILLIS);
if (years == 1) {
return Util.C.oneYearAgo();
} else {
return Util.M.yearsAgo(years);
}
}
private static long upperLimit(long unit) {

View File

@@ -198,4 +198,12 @@ public interface ChangeConstants extends Constants {
String months();
String year();
String years();
String oneSecondAgo();
String oneMinuteAgo();
String oneHourAgo();
String oneDayAgo();
String oneWeekAgo();
String oneMonthAgo();
String oneYearAgo();
}

View File

@@ -180,3 +180,11 @@ month = month
months = months
years = years
year = year
oneSecondAgo = 1 second ago
oneMinuteAgo = 1 minute ago
oneHourAgo = 1 hour ago
oneDayAgo = 1 day ago
oneWeekAgo = 1 week ago
oneMonthAgo = 1 month ago
oneYearAgo = 1 year ago