Skip to content

Commit

Permalink
Localization: Allow float variables (#5179)
Browse files Browse the repository at this point in the history
  • Loading branch information
zubiden authored and Ajaxy committed Nov 9, 2024
1 parent 2c482f8 commit fd83e36
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/util/localization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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[]);
},
Expand All @@ -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);
}
Expand Down

0 comments on commit fd83e36

Please sign in to comment.