milcoP
Background of the issue:
I am trying to translate text from a custom JavaScript on my website hidden link .
it is used on this page: hidden link
Symptoms:
No specific issue or error message mentioned.
Questions:
How can I translate a custom JavaScript?
Mihai Apetrei
Supporter
Languages:
English (English )
Timezone:
Europe/Bucharest (GMT+02:00)
Hi there.
Unfortunately, it is impossible to translate these strings with String Translation because they are added through JavaScript and not localized.
WordPress currently only offers a localization API in PHP, not directly in JavaScript. To fix this and make the text translatable, you can use the "wp_localize_script" function: https://developer.wordpress.org/reference/functions/wp_localize_script/
For more details, please check the reply from my colleague here: https://wpml.org/forums/topic/string-translation-138/#post-9698875
Kindly note that custom programming work is beyond our scope of support. If the above suggestions didn't help or you're unsure about how to achieve it, we suggest contacting one of our 3rd party contractors that specialize in custom work with WPML
https://wpml.org/contractors/
I hope that you will find this answer helpful.
Mihai