Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client needs to make strings within a custom HTML email template used in GravityForms translatable in WPML. The client is also struggling with targeting the right text-domain for each form without needing to target each form individually.

Solution:
To make the HTML email template translatable, the client should use PHP to wrap the strings in a GetText call. Here is an example of how to do this:

<?php __('Hello, world!', 'your-text-domain'); ?>

To display the string, use:

<?php _e('Hello, world!', 'your-text-domain'); ?>

It is crucial to include the 'text-domain' as the second argument in these functions. For more details on how to make your theme compatible with WPML, visit Translating the Theme You Created.

If this solution does not apply to your case, or if it seems outdated, we recommend opening a new support ticket. We also highly suggest checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. For further assistance, please contact us through the WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Andreas W. 2 months, 3 weeks ago.

Assisted by: Andreas W..

Author Posts
October 4, 2024 at 9:21 am #16253003

Sietse

Background of the issue:
Background of the issue:
I would like to target the strings inside a custom HTML email template. A template is being used in GravityForms to override the HTML style of the outgoing email HTML.
Here is a snippet of that code, including the strings
This is an example of my code:
Fake Address 101
0011 AB Netherlands
T — 030 21 203 54
W — test-domain.com
How do I mark these strings so that I can load them in my WPML editor and translate them? So to be clear, I have a template like this:

add_filter( 'gform_html_message_template_pre_send_email', 'notification_template' );
function notification_template( $template ) {
$template = '
{subject}
{message}
';
return $template;
}

And inside the body, I have a email signature that I would like to have translated. I found this documentation: https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/ but is it as easy as doing this:
Here’s how you can make the code ready for translation with WPML by replacing the actual text with placeholder dummy text while ensuring the strings are translation-ready:

Symptoms:
I am struggling with preparing my custom HTML template to be translatable. I can use the {message} field inside GravityForms but want to make it clean without HTML inside that message tab. I also struggle with targeting the right text-domain, as GravityForms generates a text domain for each form.

Questions:
How do I target all the forms (text-domain) without needing to target each form individually with the _1 addition?
How do I prepare my HTML code so it is ready for translation?

October 4, 2024 at 4:46 pm #16255439

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

WPML String Translation will be able to register and translate those strings only if you use PHP and wrap the strings into a GetText Call.

Example:
<?php __('Hello, world!', 'your-text-domain'); ?>

Relative WordPress function:
https://developer.wordpress.org/reference/functions/__/

The get text call also can look like this, if you need to echo the string:

<?php _e('Hello, world!', 'your-text-domain'); ?>

Relative WordPress function:
https://developer.wordpress.org/reference/functions/_e/

It is further important, that the second argument "text-domain" is used.

Source:
https://wpml.org/documentation/support/translating-the-theme-you-created/#wrap-all-texts-in-gettext-calls

Best regards
Andreas