From v20 (20.6.1) to v21 (21.0.0) having a boolean as a value gives a TypeError: res.match is not a function at Translator.extendTranslation (webpack-internal:///./node_modules/i18next/dist/esm/i18next.js:835:24), as res is a boolean and not a String.
"paragraphs": {
"paragraphOne": {
"text": "some example text to be highlighted",
"highlight": true
},
"paragraphTwo": {
"text": "text not highlighted",
"highlight": false
},
}
I'm using returnObjects: true to get the paragraphs object (from the example) and iterate through the results (paragraphOne and paragraphTwo) in the template (Vue). I then use the highlight boolean to know if a CSS class should be applied to that text or not (is there a better way?).
Expected behavior
No error. res typeof should be checked and if it is not a String it should not call match.
To "fix" it I just replaced true by "true" and will check for that string instead of expecting a boolean, but I'm opening this issue anyway as it might be a bug. ❔
Your Environment
i18next version: 21.5.4
The text was updated successfully, but these errors were encountered:
From v20 (20.6.1) to v21 (21.0.0) having a boolean as a value gives a
TypeError: res.match is not a function at Translator.extendTranslation (webpack-internal:///./node_modules/i18next/dist/esm/i18next.js:835:24)
, asres
is a boolean and not a String.Part of
extendTranslation
:To Reproduce
I'm using
returnObjects: true
to get theparagraphs
object (from the example) and iterate through the results (paragraphOne
andparagraphTwo
) in the template (Vue). I then use thehighlight
boolean to know if a CSS class should be applied to that text or not (is there a better way?).Expected behavior
No error.
res
typeof should be checked and if it is not a String it should not callmatch
.To "fix" it I just replaced❔
true
by"true"
and will check for that string instead of expecting a boolean, but I'm opening this issue anyway as it might be a bug.Your Environment
The text was updated successfully, but these errors were encountered: