-
Notifications
You must be signed in to change notification settings - Fork 144
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
How can I translate strings dynamically? #274
Comments
Brain fart, the load() needs to be outside of the function. Hope this helps someone else.
|
I am still sometimes experiencing that the json file isn't loaded in time for the translations to be done. |
i think modify the _T function, you can make use of a deferred object (e.g., $.Deferred()) to handle the asynchronous loading of translations : function _T(key) {
} Now, the _T function returns a promise. This allows you to use the .done() method when calling _T to handle the asynchronous nature of loading translations: $(document).ready(function () {
}); |
I'm having trouble translating strings dynamically. It seems that this is because the translation is loaded after the rest of the code.
main.js (script linked in head)
page.php
console output:
As you can see, the translation happens after the each loop.
What is the correct way to preload the translation to ensure it being available when document is ready?
The text was updated successfully, but these errors were encountered: