From: Wouter Admiraal Date: Fri, 13 Jan 2023 11:03:55 +0000 (+0100) Subject: SONAR-18175 Fix compatibility issue with older browsers X-Git-Tag: 9.9.0.65466~48 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e2d4a8fd280b78c228ed09f023f57b904521b3d1;p=sonarqube.git SONAR-18175 Fix compatibility issue with older browsers --- 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 ?? {}; }