From fa5686cd764437b372528131e642e49e5866d2de Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 5 Jun 2011 05:55:22 -0700 Subject: [PATCH] Added i18n. I think we use the word 'description' elsewhere inside Jenkins to refer to human-readable text (like job description), so I'm making description the localized string. I'm assuming Kutzi has some use for all upper-case ID, yet the notion of 'upper case' only makes sense in some locale (for example not in Chinese), so I'm now calling it ID and I'm deriving it from the English localization. --- .../main/java/hudson/model/ResultTrend.java | 41 ++++++++++--------- .../hudson/model/Messages.properties | 9 ++++ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/core/src/main/java/hudson/model/ResultTrend.java b/core/src/main/java/hudson/model/ResultTrend.java index fa887dc3b0..87f8a986df 100644 --- a/core/src/main/java/hudson/model/ResultTrend.java +++ b/core/src/main/java/hudson/model/ResultTrend.java @@ -23,6 +23,8 @@ */ package hudson.model; +import org.jvnet.localizer.Localizable; + import java.util.Locale; /** @@ -36,60 +38,59 @@ public enum ResultTrend { * Previous build was {@link Result#FAILURE} or {@link Result#UNSTABLE} * and is now {@link Result#SUCCESS}. */ - FIXED, + FIXED(Messages._ResultTrend_Fixed()), /** * Build as well as previous build (if it has a previous build) are {@link Result#SUCCESS} */ - SUCCESS, + SUCCESS(Messages._ResultTrend_Success()), /** * Previous build was {@link Result#FAILURE} and is now 'only' {@link Result#UNSTABLE}. */ - NOW_UNSTABLE("Now unstable"), + NOW_UNSTABLE(Messages._ResultTrend_NowUnstable()), /** * Build as well as previous build are {@link Result#UNSTABLE}. */ - STILL_UNSTABLE("Still unstable"), + STILL_UNSTABLE(Messages._ResultTrend_StillUnstable()), /** * Previous build (if there is one) was {@link Result#SUCCESS} and current build is {@link Result#UNSTABLE}. */ - UNSTABLE, + UNSTABLE(Messages._ResultTrend_Unstable()), /** * Build as well as previous build are {@link Result#FAILURE}. */ - STILL_FAILING("Still failing"), + STILL_FAILING(Messages._ResultTrend_StillFailing()), /** * Previous build (if there is one) was {@link Result#SUCCESS} or {@link Result#UNSTABLE} * and current build is {@link Result#UNSTABLE}. */ - FAILURE, + FAILURE(Messages._ResultTrend_Failure()), /** * Build was aborted. */ - ABORTED, + ABORTED(Messages._ResultTrend_Aborted()), /** * Build didn't run (yet). */ - NOT_BUILT("Not built"); + NOT_BUILT(Messages._ResultTrend_NotBuilt()); - private final String description; + private final Localizable description; - private ResultTrend() { - this.description = name().charAt(0) + name().substring(1).toLowerCase(Locale.ENGLISH); - } - - private ResultTrend(String description) { + private ResultTrend(Localizable description) { this.description = description; } /** - * Returns a short english description of the result. + * Returns a short human-readable description of the result. */ public String getDescription() { - return this.description; + return this.description.toString(); } - - public String getUpperCaseDescription() { - return this.description.toUpperCase(Locale.ENGLISH); + + /** + * Gets all upper case ID like token of the build status. + */ + public String getID() { + return this.description.toString(Locale.ENGLISH).toUpperCase(Locale.ENGLISH); } /** diff --git a/core/src/main/resources/hudson/model/Messages.properties b/core/src/main/resources/hudson/model/Messages.properties index be510c3925..b2c7cbba97 100644 --- a/core/src/main/resources/hudson/model/Messages.properties +++ b/core/src/main/resources/hudson/model/Messages.properties @@ -166,6 +166,15 @@ Queue.WaitingForNextAvailableExecutor=Waiting for next available executor Queue.WaitingForNextAvailableExecutorOn=Waiting for next available executor on {0} Queue.init=Restoring the build queue +ResultTrend.Aborted=Aborted +ResultTrend.Failure=Failure +ResultTrend.Fixed=Fixed +ResultTrend.NotBuilt=Not built +ResultTrend.NowUnstable=Now unstable +ResultTrend.StillFailing=Still failing +ResultTrend.StillUnstable=Still unstable +ResultTrend.Success=Success +ResultTrend.Unstable=Unstable Run.BuildAborted=Build was aborted Run.MarkedExplicitly=explicitly marked to keep the record Run.Permissions.Title=Run