Title: Issue with javascript strings not being translated
Last modified: November 22, 2024

---

# Issue with javascript strings not being translated

 *  Resolved [malimart](https://wordpress.org/support/users/malimart/)
 * (@malimart)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/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 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.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/issue-with-javascript-strings-not-being-translated/#post-18160978)
 * Thank you for reporting this issue [@malimart](https://wordpress.org/support/users/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.
 *  Thread Starter [malimart](https://wordpress.org/support/users/malimart/)
 * (@malimart)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/issue-with-javascript-strings-not-being-translated/#post-18187318)
 * I solved the issue by wrapping the translation functions in inline JS, within
   PHP tags.
 * Before
 *     ```wp-block-code
       "<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
 *     ```wp-block-code
       "<h3>" + "<?php _e( 'Admin Notices Manager', 'admin-notices-manager' ) ?>"+ "<\/h3>" +"<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.
 *  Plugin Author [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/issue-with-javascript-strings-not-being-translated/#post-18190312)
 * Thank you for the update [@malimart](https://wordpress.org/support/users/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.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Issue with javascript strings not being translated’ is closed to new 
replies.

 * ![](https://ps.w.org/admin-notices-manager/assets/icon-256x256.png?rev=2961559)
 * [Admin Notices Manager](https://wordpress.org/plugins/admin-notices-manager/)
 * [Support Threads](https://wordpress.org/support/plugin/admin-notices-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/admin-notices-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/admin-notices-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/admin-notices-manager/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [robertabela](https://wordpress.org/support/users/robert681/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/issue-with-javascript-strings-not-being-translated/#post-18190312)
 * Status: resolved