-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
🐛 Bug Report
When using t() function with an array as defaultValue that contains interpolation placeholders, the following error occurs:
TypeError: val.replace is not a function
at regexSafe (i18next.js?v=6f6c3bbd:1068:30)
at Object.safeValue (i18next.js?v=6f6c3bbd:1164:76)
at i18next.js?v=6f6c3bbd:1187:32
at Array.forEach (<anonymous>)
Additionally, when using an object as defaultValue with interpolation, the interpolation does not work as expected.
To Reproduce
Using array with interpolation in defaultValue:
t("missingKeyHere", {
defaultValue: ["Tickets {{value}}"],
value: 10,
returnObjects: true,
})
Using object with interpolation in defaultValue:
t("missingKeyHere", {
defaultValue: { ticket: "Tickets {{value}}" },
value: 10,
returnObjects: true,
})
Expected behavior
Array interpolation in defaultValue should work the same way as when translations are provided via translation JSON files.
Both array and object interpolation should properly replace {{value}} with the provided value (10 in this case)
Metadata
Metadata
Assignees
Labels
No labels