diff --git a/mozilla/calendar/base/content/calendar-task-tree.xml b/mozilla/calendar/base/content/calendar-task-tree.xml index df2a744cef3..efb226a12b2 100644 --- a/mozilla/calendar/base/content/calendar-task-tree.xml +++ b/mozilla/calendar/base/content/calendar-task-tree.xml @@ -218,16 +218,26 @@ if (aTask && aTask.dueDate && aTask.dueDate.isValid){ var dur = aTask.dueDate.subtractDate(now()); if (!dur.isNegative) { - if (dur.days > 1) { - return dur.days + " " + calGetString("calendar", "days"); - } else if (dur.days == 1) { - return "1 " + calGetString("calendar", "day"); - } else if (dur.hours > 1) { - return dur.hours + " " + calGetString("calendar", "hours"); - } else if (dur.hours == 1) { - return "1 " + calGetString("calendar", "hour"); - } else - return "< 1" + calGetString("calendar", "hour"); + // TODO MOZILLA_1_8_BRANCH We should use Pluralform.jsm on + // trunk here to provide better localization. Use different + // strings for 1,2 and N for now. + var minutes = Math.ceil(dur.inSeconds / 60); + if (minutes >= 4320) { // 3 days or more + return calGetString("calendar", "dueInDaysN", [dur.days]); + } else if (minutes >= 2880) { // 2 days or more + return calGetString("calendar", "dueInDays2"); + } else if (minutes >= 1440) { // 1 day or more + return calGetString("calendar", "dueInDays1"); + } else if (minutes >= 180) { // 3 hours or more + return calGetString("calendar", "dueInHoursN", [dur.hours]); + } else if (minutes >= 120) { // 2 hours or more + return calGetString("calendar", "dueInHours2"); + } else if (minutes >= 60) { // 1 hour or more + return calGetString("calendar", "dueInHours1"); + } else { + // Less than one hour + return calGetString("calendar", "dueInLessThanOneHour"); + } } } return null; diff --git a/mozilla/calendar/locales/en-US/chrome/calendar/calendar.properties b/mozilla/calendar/locales/en-US/chrome/calendar/calendar.properties index 020c06809b5..9b494ec426a 100644 --- a/mozilla/calendar/locales/en-US/chrome/calendar/calendar.properties +++ b/mozilla/calendar/locales/en-US/chrome/calendar/calendar.properties @@ -370,3 +370,15 @@ oneMonthForward=One Month Forward oneWeekBack=One Week Back oneWeekForward=One Week Forward gotoToday=Go to Today + +# Task tree, "Due In" column. +dueInDays1=1 day +# Used for "2 days" +dueInDays2=2 days +# Used for more than 2 days +dueInDaysN=%1$S days + +dueInHours1=1 hour +dueInHours2=2 hours +dueInHoursN=%1$S hours +dueInLessThanOneHour=< 1 hour