From e2d4a8fd280b78c228ed09f023f57b904521b3d1 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Fri, 13 Jan 2023 12:03:55 +0100 Subject: [PATCH] SONAR-18175 Fix compatibility issue with older browsers --- server/sonar-web/src/main/js/helpers/l10n.ts | 5 ++++- server/sonar-web/src/main/js/helpers/l10nBundle.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/helpers/l10n.ts b/server/sonar-web/src/main/js/helpers/l10n.ts index 0f4d35e40e7..ab7eacf220f 100644 --- a/server/sonar-web/src/main/js/helpers/l10n.ts +++ b/server/sonar-web/src/main/js/helpers/l10n.ts @@ -42,7 +42,10 @@ export function translateWithParameters( if (message) { return parameters .map((parameter) => String(parameter)) - .reduce((acc, parameter, index) => acc.replaceAll(`{${index}}`, () => parameter), message); + .reduce( + (acc, parameter, index) => acc.replace(new RegExp(`\\{${index}\\}`, 'g'), () => parameter), + message + ); } if (process.env.NODE_ENV === 'development') { // eslint-disable-next-line no-console diff --git a/server/sonar-web/src/main/js/helpers/l10nBundle.ts b/server/sonar-web/src/main/js/helpers/l10nBundle.ts index d89b35f8fbe..a3b068bcc3f 100644 --- a/server/sonar-web/src/main/js/helpers/l10nBundle.ts +++ b/server/sonar-web/src/main/js/helpers/l10nBundle.ts @@ -83,7 +83,7 @@ function getPreferredLanguage() { return window.navigator.languages ? window.navigator.languages[0] : window.navigator.language; } -function getL10nBundleFromCache() { +function getL10nBundleFromCache(): L10nBundle { return (window as unknown as any).sonarQubeL10nBundle ?? {}; } -- 2.39.5