-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
$.t is not a function with slow networks #45
Comments
you access $.t too early...before calling jqueryI18next.init |
This: $(function () {
var alertTxt = $.t('NOTIFICATION_CENTER.LOADING_NOTIFICATIONS'); // The error happens here
}); should only be called, after this: jqueryI18next.init(i18next, $, { useOptionsAttr: true }); |
I added consol.logs to the code and am now calling the CCC.Header_TranslateBody synchronously from the . See the result in the console. Error happening on slow networks only. let CCC = window.CCC || {};
(function() {
const portalLng = "de-de";
this.Header_TranslateBody = function () {
i18next
.use(i18nextBrowserLanguageDetector)
.use(i18nextHttpBackend)
.init({
debug: true, //To comment
fallbackLng: 'en',
lowerCaseLng: true,
backend: {
loadPath: '/locales/' + portalLng +'.json'
}
}, function (err, t) {
if (err) return console.error(err);
console.log('i18next initialized');//To comment
jqueryI18next.init(i18next, $, { useOptionsAttr: true });
console.log('jqueryI18next initialized');//To comment
i18next.changeLanguage(portalLng, () => {
i18n_updateContent();
});
i18n_updateContent();
});
}
this.i18n_updateContent = function () {
$('body').localize();
}
}).call(CCC); |
Please create a minimal reproducible example... not just code snippets |
btw: it may also be jquery is not loaded when calling |
I just checked, jquery is correctly loaded beforehand. |
🐛 Bug Report
I am getting
$.t is not a function
on page load only for slow network users. I could reproduce it using Google Chrome developer console, enabling the network throttle (preset Fast 3G) from the Network tab.To Reproduce
Here is the footer of my HTML web page:
And the content of the header ccc.js:
Expected behavior
It looks like with slow loading times the framework loads too late. I don't know how to fix it.
Your Environment
The text was updated successfully, but these errors were encountered: