• I am trying to edit and translate the woocommerce email notifications and this is what I’ve done so far:

    1 – Overridden the email under child-theme/woocommerce/emails/customer-processing-order.php
    2 – Added <p><?php esc_html_e( 'Text to be translated.', 'woocommerce' ); ?></p> to the customer-processing-order template overridden.

    However these strings are not appearing under Loco Translate > Plugins > Woocommerce (under any of the languages) so i can translate them. I have tried the Sync button, however they still do not show up.

    Am I doing anything wrong or how should I do this?

    Thank you

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tim W

    (@timwhitlock)

    Many people have reported issues with translation of WooCommerce emails. If I recall correctly, I think they’re stored as configurable options somewhere in your admin screens.

    However they work, this is not a topic I can help with. I suggest you check this forum for people reporting this previousl. Failing that ask WooCommerce support.

    Thread Starter kraky9

    (@rdc4)

    I know that you are referring to the additional content boxes that you can add extra strings, but I am not talking about those. I have overridden the Woocommerce email templates on my child theme and added a few additional phrases using the esc_html_e() function, however they are not appearing on the Loco Translate plugin so I can translate them.

    Plugin Author Tim W

    (@timwhitlock)

    Sorry, yes. I see now.

    You can’t simply add strings this way and expect them to show up in the woocommerce translation files. You need to internationalize and then translate your child theme.

    See How to translate a WordPress child theme with Loco Translate.

    You must define your child theme’s own text domain, (optionally generate a translation template for it) and then add translations for it via the editor. In addition to your code above you must also ensure your child theme is loading the text domain on start up.

    If this all sounds new to you, I suggest reading the WordPress documentation on theme internationalization.

    Thread Starter kraky9

    (@rdc4)

    I’ve gone through the documentation and I still do not understand how can I define a text domain to a “child plugin” (not sure if this is what I need). My child theme already has a text domain defined and it’s working but I don’t think that’s what I need because I tried adding the strings to the file with the child theme’s text domain and they still do not show up. Just to be clear the path of the file that I am adding the strings to is: themechild/woocommerce/emails/customer-on-hold-order.php
    So how can I solve this?

    Thank you for your help!

    Plugin Author Tim W

    (@timwhitlock)

    If your child theme has a working text domain then use it. esc_html_e('Text to be translated.','woocommerce') is wrong. That is WooCommerce’s text domain. Don’t try adding anything to it.

    esc_html_e('Text to be translated.','your-child-theme') would be correct. That is your text domain. This is explained as clearly as I could manage in the guide I linked to.

    After adding strings with the correct text domain you can use Loco Translate to create a new POT file for your child theme, or sync your existing POT file with any updated code you’ve added.

    Every time you update your child theme POT file, you need to open your child theme translation file and sync it to get the changes. If you don’t understand this process, see Working with POT files in Loco Translate.

    Thread Starter kraky9

    (@rdc4)

    I’ve tried doing that and still not working. Maybe I’m missing something?

    Check screenshots:
    Screenshot 1
    Screenshot 2
    Screenshot 3

    • This reply was modified 4 years, 4 months ago by kraky9.
    Plugin Author Tim W

    (@timwhitlock)

    cmb2 sounds like a name I’ve heard before. Is that your child theme text domain? Are you sure it’s not in use by something else?

    Anyway, assuming it’s correct: Your screenshot shows the PO syncing to the POT, which will not pick up code changes unless the POT has been synced first. Have you done that? Have you updated cmb2.pot by syncing it to the source code since you added your code?

    If that part isn’t working, have you defined your text domain in the style.css headers?

    Thread Starter kraky9

    (@rdc4)

    I have not synced the POT file, how can I do that?

    Plugin Author Tim W

    (@timwhitlock)

    Open the POT file in the Loco Translate editor by clicking “Edit template” from bundle overview tab.

    Then click Sync.

    Then – if you’re happy – click Save.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Woocommerce Emails Translation’ is closed to new replies.