You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to dynamic translate my GlobalConstant.js which is not a component or function. I understand that I've to use an API event listener to dynamic changes but I am not sure how should I implement it into my code. Also, I can't even show the default en text.
Any advice is appreciated. TIA
Sample of the API event listener
i18next.on('languageChanged init', () => {
// what to put here?
});
import * as Constants from '../../utils/GlobalConstant";
export function Component() {
let namingLabel = [];
// other codes...
namingLabel.push(Constants.label);
// other codes...
}
Errors
i18next: hasLoadedNamespace: i18next was not initialized undefined
i18next.js:22 i18next::translator: key "firstName" for languages "en" won't get resolved as namespace "translation" was not yet loaded This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!
i18next::translator: missingKey undefined translation firstName firstName
On the front end it will just show "firstName" instead of "First Name"
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm trying to dynamic translate my GlobalConstant.js which is not a component or function. I understand that I've to use an API event listener to dynamic changes but I am not sure how should I implement it into my code. Also, I can't even show the default en text.
Any advice is appreciated. TIA
Sample of the API event listener
Code as below
i18n.js
en/translation.json
jp/translation.json
GlobalConstant.js
Component.js
Errors
On the front end it will just show "firstName" instead of "First Name"
The text was updated successfully, but these errors were encountered: