From b8c759cc3d00365bc88e1d9a9d7695caca32bd09 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 15 Sep 2015 10:17:05 +0200 Subject: [PATCH] improve formatting of LEVEL measures --- server/sonar-web/src/main/js/libs/application.js | 15 ++++++++++++++- .../main/resources/org/sonar/l10n/core.properties | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/libs/application.js b/server/sonar-web/src/main/js/libs/application.js index bdbc78a7524..82f612db355 100644 --- a/server/sonar-web/src/main/js/libs/application.js +++ b/server/sonar-web/src/main/js/libs/application.js @@ -500,6 +500,18 @@ function closeModalWindow () { return String.fromCharCode(97 + value - 1).toUpperCase(); }; + + /** + * Format a level measure + * @param {number} value + */ + var levelFormatter = function (value) { + var l10nKey = 'metric.level.' + value, + result = window.t(l10nKey); + // if couldn't translate, return the initial value + return l10nKey !== result ? result : value; + }; + /** * Format a measure according to its type * @param measure @@ -524,7 +536,8 @@ function closeModalWindow () { }, 'WORK_DUR': durationFormatter, 'SHORT_WORK_DUR': shortDurationFormatter, - 'RATING': ratingFormatter + 'RATING': ratingFormatter, + 'LEVEL': levelFormatter }; if (measure != null && type != null) { formatted = formatters[type] != null ? formatters[type](measure) : measure; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 29ff7210aae..4a5d04c377c 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2787,6 +2787,10 @@ metric.type.DISTRIB=Distribution metric.type.RATING=Rating metric.type.WORK_DUR=Work Duration +metric.level.ERROR=Error +metric.level.WARN=Warning +metric.level.OK=Ok + #------------------------------------------------------------------------------ # -- 2.39.5