WPIntell

Source evidence

Issue with javascript strings not being translated

Admin Notices Manager · support · 2024-11-22T13:28:00+00:00

mixedsentiment
mediumseverity
0.72relevance
3replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

3 / 20 rows with source links

15.0% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

17 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
malimart resolved
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 the print_footer_scripts() method. As far as I know wordpress’s javascript i18n tools ( wp i18n make-pot and wp 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 using wp_set_script_translations() function to link the script to the translation files. Thank you for reporting this issue @malimart We will look into it and if need be, include a fix in the next update of the plugin. Should you have any other questions, please do not hesitate to ask. I solved the issue by wrapping the translation functions in inline JS, within PHP tags. Before "<h3>" + __( 'Admin Notices Manager', 'admin-notices-manager' ) + "<\/h4>" + "<p>" + __( 'From now onward, all the admin notices will be displayed here.', 'admin-notices-manager' ) + "</p>", Now "<h3>" + "<?php _e ( 'Admin Notices Manager', 'admin-notices-manager' ) ?>" + "<\/h 3 >" + "<p>" + "<?php _e ( 'From now onward, all the admin notices will be displayed here.', 'admin-notices-manager' ) ?>" + "</p>", I also fixed the closing tag of the h3 element. Thank you for the update @malimart We will include the fix / update in the next plugin update. In the meantime, should you have any other questions, please do not hesitate to ask. Have a great day.

Comments

3 shown
robertabela 2024-11-26T08:30:00+00:00

Thank you for reporting this issue @malimart We will look into it and if need be, include a fix in the next update of the plugin. Should you have any other questions, please do not hesitate to ask.

malimart 2024-12-09T13:33:00+00:00

I solved the issue by wrapping the translation functions in inline JS, within PHP tags. Before "<h3>" + __( 'Admin Notices Manager', 'admin-notices-manager' ) + "<\/h4>" + "<p>" + __( 'From now onward, all the admin notices will be displayed here.', 'admin-notices-manager' ) + "</p>", Now "<h3>" + "<?php _e ( 'Admin Notices Manager', 'admin-notices-manager' ) ?>" + "<\/h 3 >" + "<p>" + "<?php _e ( 'From now onward, all the admin notices will be displayed here.', 'admin-notices-manager' ) ?>" + "</p>", I also fixed the closing tag of the h3 element.

robertabela 2024-12-10T16:34:00+00:00

Thank you for the update @malimart We will include the fix / update in the next plugin update. In the meantime, should you have any other questions, please do not hesitate to ask. Have a great day.