• Resolved malimart

    (@malimart)


    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

    (@robert681)

    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.

    Thread Starter malimart

    (@malimart)

    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' ) ?>"+ "<\/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

    (@robert681)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.