From 94c91d4c3f9d9c935455414439bd4e5e1a1a342a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 8 Jul 2023 03:10:51 +0300 Subject: [PATCH] Fix recursive call in `translate()` --- frontend/src/Utilities/String/translate.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/Utilities/String/translate.js b/frontend/src/Utilities/String/translate.js index 2858014d0..7483b27aa 100644 --- a/frontend/src/Utilities/String/translate.js +++ b/frontend/src/Utilities/String/translate.js @@ -18,13 +18,14 @@ function getTranslations() { const translations = getTranslations(); -export default function translate(key, args = '') { +export default function translate(key, args = []) { + const translation = translations[key] || key; + if (args) { - const translatedKey = translate(key); - return translatedKey.replace(/\{(\d+)\}/g, (match, index) => { + return translation.replace(/\{(\d+)\}/g, (match, index) => { return args[index]; }); } - return translations[key] || key; + return translation; }