aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/helpers/l10n.ts
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-01-16 13:49:10 +0100
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-01-25 15:16:50 +0100
commit49391d2eff65209068acc31e41393b9617fb2458 (patch)
tree705191348ecc0cbc2db933f3c20ec8edad26c688 /server/sonar-web/src/main/js/helpers/l10n.ts
parente85902788fd722f1c17d214d8be15eea5cf276e0 (diff)
downloadsonarqube-49391d2eff65209068acc31e41393b9617fb2458.tar.gz
sonarqube-49391d2eff65209068acc31e41393b9617fb2458.zip
Migrate App to tsx and clean up measures related types
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/l10n.ts')
-rw-r--r--server/sonar-web/src/main/js/helpers/l10n.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/helpers/l10n.ts b/server/sonar-web/src/main/js/helpers/l10n.ts
index 522bffcc922..df95089855f 100644
--- a/server/sonar-web/src/main/js/helpers/l10n.ts
+++ b/server/sonar-web/src/main/js/helpers/l10n.ts
@@ -153,18 +153,21 @@ export function getLocalizedDashboardName(baseName: string) {
}
export function getLocalizedMetricName(
- metric: { key: string; name: string },
+ metric: { key: string; name?: string },
short?: boolean
): string {
const bundleKey = `metric.${metric.key}.${short ? 'short_name' : 'name'}`;
const fromBundle = translate(bundleKey);
if (fromBundle === bundleKey) {
- return short ? getLocalizedMetricName(metric) : metric.name;
+ if (short) {
+ return getLocalizedMetricName(metric);
+ }
+ return metric.name || metric.key;
}
return fromBundle;
}
-export function getLocalizedCategoryMetricName(metric: { key: string; name: string }) {
+export function getLocalizedCategoryMetricName(metric: { key: string; name?: string }) {
const bundleKey = `metric.${metric.key}.extra_short_name`;
const fromBundle = translate(bundleKey);
return fromBundle === bundleKey ? getLocalizedMetricName(metric, true) : fromBundle;