From fd83e36aeb146b9f8b518281b52fb457f752f804 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Sat, 9 Nov 2024 15:43:34 +0400 Subject: [PATCH] Localization: Allow float variables (#5179) --- src/util/localization/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/localization/index.ts b/src/util/localization/index.ts index 3f08fb4dc..8d07fc74c 100644 --- a/src/util/localization/index.ts +++ b/src/util/localization/index.ts @@ -369,7 +369,7 @@ function processTranslation( const finalString = variableEntries.reduce((result, [key, value]) => { if (value === undefined) return result; - const valueAsString = Number.isInteger(value) ? formatters!.number.format(value as number) : String(value); + const valueAsString = Number.isFinite(value) ? formatters!.number.format(value as number) : String(value); return result.replace(`{${key}}`, valueAsString); }, string); @@ -412,9 +412,9 @@ function processTranslationAdvanced( return renderText(curr, filters, { markdownPostProcessor: (part: string) => { return variableEntries.reduce((result, [key, value]): TeactNode[] => { - if (!value) return result; + if (value === undefined) return result; - const preparedValue = Number.isInteger(value) ? formatters!.number.format(value as number) : value; + const preparedValue = Number.isFinite(value) ? formatters!.number.format(value as number) : value; return replaceInStringsWithTeact(result, `{${key}}`, preparedValue); }, [part] as TeactNode[]); }, @@ -423,9 +423,9 @@ function processTranslationAdvanced( } return variableEntries.reduce((result, [key, value]): TeactNode[] => { - if (!value) return result; + if (value === undefined) return result; - const preparedValue = Number.isInteger(value) ? formatters!.number.format(value as number) : value; + const preparedValue = Number.isFinite(value) ? formatters!.number.format(value as number) : value; return replaceInStringsWithTeact(result, `{${key}}`, preparedValue); }, tempResult); }