提交 a3bac8aa 编写于 作者: M mindless

[HUDSON-1670] use Localizables as parameters to another Localizable when creating

a HealthReport (for both Build Stability and Test Results).
When already-translated strings are used, these go into the cached health report,
so all users see language of the person who cached it rather than their own language.
Localizer package needs a fix so that Localizable.toString() defaults to
LocaleProvider.getLocale() rather than Locale.getDefault().. then these strings
will translate correctly to the language of the current request.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15320 71c3de6d-444a-0410-be80-ed276b4c234a
上级 167f181c
......@@ -89,6 +89,7 @@ import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.StackedAreaRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.ui.RectangleInsets;
import org.jvnet.localizer.Localizable;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.WebMethod;
......@@ -860,16 +861,16 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
score--;
}
String description;
Localizable description;
if (failCount == 0) {
description = Messages.Job_NoRecentBuildFailed();
description = Messages._Job_NoRecentBuildFailed();
} else if (totalCount == failCount) {
// this should catch the case where totalCount == 1
// as failCount must be between 0 and totalCount
// and we can't get here if failCount == 0
description = Messages.Job_AllRecentBuildFailed();
description = Messages._Job_AllRecentBuildFailed();
} else {
description = Messages.Job_NOfMFailed(failCount, totalCount);
description = Messages._Job_NOfMFailed(failCount, totalCount);
}
return new HealthReport(score, Messages._Job_BuildStability(description));
}
......
......@@ -124,11 +124,11 @@ public abstract class AbstractTestResultAction<T extends AbstractTestResultActio
final int totalCount = getTotalCount();
final int failCount = getFailCount();
int score = (totalCount == 0) ? 100 : (int) (100.0 * (1.0 - ((double)failCount) / totalCount));
Localizable description;
Localizable description, displayName = Messages._AbstractTestResultAction_getDisplayName();
if (totalCount == 0) {
description = Messages._AbstractTestResultAction_zeroTestDescription(getDisplayName());
description = Messages._AbstractTestResultAction_zeroTestDescription(displayName);
} else {
description = Messages._AbstractTestResultAction_TestsDescription(getDisplayName(), failCount, totalCount);
description = Messages._AbstractTestResultAction_TestsDescription(displayName, failCount, totalCount);
}
return new HealthReport(score, description);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册