Issue with javascript strings not being translated
-
I am currently using your Admin Notices Manager plugin (v1.5.0) and encountered an issue related to string translations within javascript.
While translations in php work as expected, the strings within javascript are not being translated. I found that the javascript code containing translatable strings is embedded within a
<script>
tag in a php file, specifically in theprint_footer_scripts()
method.As far as I know wordpress’s javascript i18n tools (
wp i18n make-pot
andwp i18n make-json
) do not scan inline javascript in php files.For example, the following string does not load its translation:
__("From now onward, all the admin notices will be displayed here.", "admin-notices-manager")
I recommend extracting the javascript code from the php file and placing it into a separate
.js
file and then usingwp_set_script_translations()
function to link the script to the translation files.
- You must be logged in to reply to this topic.