Skip Navigation

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 4 replies, has 2 voices.

Last updated by jonathanF-3 3 months ago.

Assigned support staff: Bobby.

Author Posts
March 15, 2021 at 10:10 pm #8314967


We are trying to translate string in a custom function for Woocommerce. We've wrapped the sprintf in (__ get text and scanned the theme for string. Found the string and added the 2nd language translation.

Problem : The translation isn't showing on front end.

Here's a screencast: hidden link

March 16, 2021 at 3:00 am #8316053


Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Thank you for the screencast! If possible please add a text domain to the wrapped strings, for example

(...., 'wc-custom-notice'), then re scan your theme and filter String translation using that new domain you attached to these strings. It should pick up both strings.

Then re translate and let me know your results.

if that does not work, switch __() to _e() as a test and let me know your results.

March 16, 2021 at 3:55 am #8316335


Great, it worked just fine. Thanks!

How can we tranlsate the ($name) in this part :

French should stay: "Frais commande minimum"
English should be : "Minimum order fee"

add_action( 'woocommerce_cart_calculate_fees', 'ajout_frais_commande_min' );
if ( ! function_exists( 'ajout_frais_commande_min' ) ) {

function ajout_frais_commande_min( $cart ) {
$cart_contents_total = $cart->get_cart_contents_total();
if ( $cart_contents_total < 15 ) {
$name = 'Frais commande minimum';
$amount = 5;
$taxable = true;
$tax_class = '';
$cart->add_fee( $name, $amount, $taxable, $tax_class );

March 16, 2021 at 6:56 pm #8325143


Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)


You should be able to wrap the string the same way as done already
$name = __('Frais commande minimum', 'your-theme-domain');

Related Documentation:

March 17, 2021 at 3:31 am #8327003


My issue is resolved now using the above suggestion. Thank you!