Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read properties of undefined (reading '0') in i18next function (Custom translate) in Arabic language #123

Open
NimnadMihiranga opened this issue Sep 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@NimnadMihiranga
Copy link

I encountered an issue after switching the language to Arabic in my application. The following error is thrown in the console:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0') at r.i18next (runtime.4a59971d836709dfc991.js:6:2322) at library.b717a95e17e4d6e9f5ca.js:350:1082 at e.exports.ChartWidget._setActions (library.b717a95e17e4d6e9f5ca.js:353:3062) at e.exports.ChartWidget._makeDefaultModel (library.b717a95e17e4d6e9f5ca.js:342:2175) at e.exports.ChartWidget._init (library.b717a95e17e4d6e9f5ca.js:341:2987) at e.exports.ChartWidget._requestMetadataAndProcessModel (library.b717a95e17e4d6e9f5ca.js:345:1601)

The error seems to be related to the i18next function in the charting library, specifically when handling the Arabic language.

Steps to Reproduce:

Load the application.
Switch the language to Arabic.
Check the console for the error.

code of the error raising part

r.i18next = (e, a={}, d, c=r.g.language) => { if (null === e) { if (Array.isArray(d)) return d[void 0 === a.count ? 0 : r._plural[c](a.count)].replace(/{(\w+)}/g, ( (e, d) => void 0 !== (a.replace || a)[d] ? (a.replace || a)[d] : e)); if ("object" == typeof d) { if (r.g.customTranslateFunction) { const e = r.g.customTranslateFunction(d.en[r._plural.en(a.count)], d.en[0], d[r.g.language][r._plural[r.g.language](a.count)]); if (null !== e) return e.replace(/{(\w+)}/g, ( (e, d) => void 0 !== (a.replace || a)[d] ? (a.replace || a)[d] : e)) } return d[r.g.language] ? r.i18next(null, a, d[r.g.language]) : r.i18next(null, a, d.en, "en") } } else if (d && e) { const c = ${e}${a.context ? _${a.context} : ""}; if (d[c]) return r.i18next(null, a, d[c]) } return "number" == typeof e ? e.toString() : "string" != typeof e ? "" : e }

Potential Cause: The issue seems to occur when the Arabic translation is missing or improperly defined, causing the function to attempt to access an undefined property.(Error raises for the word 'More settings' ,

Screenshot 2024-09-03 075050

@romfrancois
Copy link
Contributor

Yes it's a known issue that should be fixed shortly; will let you know once it's available.

@romfrancois romfrancois added the bug Something isn't working label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants