• Hello guys,

    im using the following code in the woocommerce plugin, under loop/no-products-found.php

    ?>
    <p class="woocommerce-info"><?php _e( 'Unfortunately no matching articles were found online. Write us your request, we will contact you immediately if we can offer you a suitable article from our offline network: <a href="mailto:[email protected]">[email protected]</a>', 'woocommerce'); ?></p>

    my issue is that this string with _e is not translated. It appears in english all the time. The original code, before I changed it, looked like this

    <p class="woocommerce-info"><?php esc_html_e( 'Unfortunately no matching articles were found online. Write us your request, we will contact you immediately if we can offer you a suitable article from our offline network: [email protected]', 'woocommerce' ); ?></p>
    

    This one was translated into German automatically.

    What am I doing wrong?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You cannot change anything in the passed string and expect it to still translate. Translation is managed by exact string matches. To translate custom text, you either need to define your own plugin’s textdomain and generate the appropriate gettext files or filter through “gettext” to override the usual gettext translation routines.

    BTW, it’s not advisable to not escape output in some manner in the way esc_html_e() does.

    Thread Starter user02122019

    (@user02122019)

    My problem is that I need the link inside this esc_html_e to be a clickable link, that is why i changed it to a _e function instead esc_html_e

    Regarding your actual post, does it mean that the plugin has fixed strings for another language? So I can find where those strings are located and change them too, right?

    Moderator bcworkz

    (@bcworkz)

    Only if you have the gettext utilities installed to re-compile the language files. The file that is used to actually do the translation is a compressed machine readable file which you cannot make sense of. You would actually be editing a human readable form of this file, which is then compiled into the machine readable file. The other problem with doing this is when you update the plugin your changes will be overwritten and you’ll need to reapply your changes.

    Your viable options are as I said earlier. You’re right about escaping, if the output is all hard coded and not sourced from the DB there is no need to escape output.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘_e () function – string is not translated’ is closed to new replies.