提交 e30738e5 编写于 作者: C cactusman

Fixed i18n time's suffix.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7160 71c3de6d-444a-0410-be80-ed276b4c234a
上级 2df9f2c3
......@@ -402,18 +402,18 @@ public class Util {
long seconds = duration / ONE_SECOND_MS;
if (years > 0)
return makeTimeSpanString(years, Messages.Util_year(), months, Messages.Util_month());
return makeTimeSpanString(years, Messages.Util_year(years), months, Messages.Util_month(months));
else if (months > 0)
return makeTimeSpanString(months, Messages.Util_month(), days, Messages.Util_day());
return makeTimeSpanString(months, Messages.Util_month(months), days, Messages.Util_day(days));
else if (days > 0)
return makeTimeSpanString(days, Messages.Util_day(), hours, Messages.Util_hour());
return makeTimeSpanString(days, Messages.Util_day(days), hours, Messages.Util_hour(hours));
else if (hours > 0)
return makeTimeSpanString(hours, Messages.Util_hour(), minutes, Messages.Util_minute());
return makeTimeSpanString(hours, Messages.Util_hour(hours), minutes, Messages.Util_minute(minutes));
else if (minutes > 0)
return makeTimeSpanString(minutes, Messages.Util_minute(), seconds, Messages.Util_second());
return makeTimeSpanString(minutes, Messages.Util_minute(minutes), seconds, Messages.Util_second(seconds));
else
// Durations less than a minute are only expressed in seconds (no ms).
return combine(seconds, Messages.Util_second());
return Messages.Util_second(seconds);
}
......@@ -430,9 +430,9 @@ public class Util {
String bigLabel,
long smallUnit,
String smallLabel) {
String text = combine(bigUnit, bigLabel);
String text = bigLabel;
if (bigUnit < 10)
text += ' ' + combine(smallUnit, smallLabel);
text += ' ' + smallLabel;
return text;
}
......@@ -452,7 +452,7 @@ public class Util {
public static String combine(long n, String suffix) {
String s = Long.toString(n)+' '+suffix;
if(n!=1)
s += Messages.Util_timeSuffix();
s += Messages.Util_countSuffix();
return s;
}
......
......@@ -3,13 +3,13 @@ FilePath.validateAntFileMask.whitespaceSeprator=\
FilePath.validateAntFileMask.doesntMatchAndSuggest=\
''{0}'' doesn''t match anything, but ''{1}'' does. Perhaps that''s what you mean?
Util.second=second
Util.minute=minute
Util.hour =hour
Util.day =day
Util.month =month
Util.year =year
Util.timeSuffix=s
Util.second={0} {0,choice,0#seconds|1#second|1<seconds}
Util.minute={0} {0,choice,0#minutes|1#minute|1<minutes}
Util.hour ={0} {0,choice,0#hours|1#hour|1<hours}
Util.day ={0} {0,choice,0#days|1#day|1<days}
Util.month ={0} {0,choice,0#months|1#month|1<months}
Util.year ={0} {0,choice,0#years|1#year|1<years}
Util.countSuffix=s
# ideally it should be "{0} ago" but this saves more space
# another implication of this is that where we use this,
......
Util.second=\u79d2
Util.minute=\u5206
Util.hour =\u6642\u9593
Util.day =\u65e5
Util.month =\u6708
Util.year =\u5e74
Util.timeSuffix=
Util.pastTime={0}\u524d
\ No newline at end of file
Util.second={0} \u79d2
Util.minute={0} \u5206
Util.hour ={0} \u6642\u9593
Util.day ={0} \u65e5
Util.month ={0} \u6708
Util.year ={0} \u5e74
Util.countSuffix=
Util.pastTime={0}\u524d
......@@ -37,18 +37,18 @@ public class UtilTest extends TestCase {
// We're still working on the assumption that a month is 30 days, so there will
// be 5 days at the end of the year that will be "12 months" but not "1 year".
// First check 359 days.
assertEquals("11 " + Messages.Util_month() + Messages.Util_timeSuffix(), Util.getTimeSpanString(31017600000L));
assertEquals(Messages.Util_month(11), Util.getTimeSpanString(31017600000L));
// And 362 days.
assertEquals("12 " + Messages.Util_month() + Messages.Util_timeSuffix(), Util.getTimeSpanString(31276800000L));
assertEquals(Messages.Util_month(12), Util.getTimeSpanString(31276800000L));
// 11.25 years - Check that if the first unit has 2 or more digits, a second unit isn't used.
assertEquals("11 " + Messages.Util_year() + Messages.Util_timeSuffix(), Util.getTimeSpanString(354780000000L));
assertEquals(Messages.Util_year(11), Util.getTimeSpanString(354780000000L));
// 9.25 years - Check that if the first unit has only 1 digit, a second unit is used.
assertEquals("9 " + Messages.Util_year() + Messages.Util_timeSuffix() + " 3 " + Messages.Util_month() + Messages.Util_timeSuffix(), Util.getTimeSpanString(291708000000L));
assertEquals(Messages.Util_year(9)+ " " + Messages.Util_month(3), Util.getTimeSpanString(291708000000L));
// 67 seconds
assertEquals("1 " + Messages.Util_minute() + " 7 " + Messages.Util_second() + Messages.Util_timeSuffix(), Util.getTimeSpanString(67000L));
assertEquals(Messages.Util_minute(1) + " " + Messages.Util_second(7), Util.getTimeSpanString(67000L));
// 17 seconds - Check that times less than a minute only use seconds.
assertEquals("17 " + Messages.Util_second() + Messages.Util_timeSuffix(), Util.getTimeSpanString(17000L));
assertEquals(Messages.Util_second(17), Util.getTimeSpanString(17000L));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册