• Resolved Nicolas V.

    (@nicolasviallet)


    Hi there,

    This is Nico from the WPML Compatibility team. I would like to report a compatibility issue with?MC4WP integration with WooCommerce.

    1. Steps to Reproduce

    • Go to “MC4WP > Integration > WooCommerce Checkout
    • Enable it
    • Add a custom Checkbox label text and save
    • You won’t be able to translate it

    2. Workaround provided to the client

    • Open the …/wp-content/plugins/mailchimp-for-wp/includes/integrations/class-integration.php file.
    • Look for line 168.
    • Replace:
    public function get_label_text()
    {
    $integration = $this;
    $label = $this->options['label'];

    if (empty($label)) {
    $default_options = $this->get_default_options();
    $label = $default_options['label'];
    }
    • With:
    public function get_label_text()
    {
    $integration = $this;
    $label = $this->options['label'];

    if (empty($label)) {
    $default_options = $this->get_default_options();
    $label = __( $default_options['label'], 'mailchimp-for-wp' );
    } else {
    do_action( 'wpml_register_single_string', 'mailchimp-for-wp', 'Checkout Label', $label );
    $label = apply_filters( 'wpml_translate_single_string', $label , 'mailchimp-for-wp', 'Checkout Label' );
    }

    Could you please check if it’s possible to?fix this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hello @nicolasviallet,

    We recently started running the saved checkbox label text through the __($text, $domain) translation functions provided by WordPress core to accomodate translation plugins like WPML or Loco Translate to translate user-supplied stored values as well.

    Instead of us running the text through the WPML specific filter, wouldn’t it make more sense for WPML to hook into something like the gettext filter instead? Here’s an example:

    add_filter('gettext', function($translation, $text, $domain) {
    if ($translation !== $text) {
    return $translation;
    }

    return apply_filters('wpml_translate_single_string', $text, $domain);
    }, 10, 3);

    This is just an example, I’m sure you folks over at WPML can work out something smarter. I’m mostly wondering why we should run a WPML specific filter when the text is already run through a bunch translation-related filters?

    Thank you!
    Danny

    Thread Starter Nicolas V.

    (@nicolasviallet)

    Hi Danny,

    Apologies for the delayed response, I missed the notification.

    With this approach, when a client changes the default text to a customized one, they will need to register it as an admin string and rescan your plugin to detect the string. This is why we recommended explicitly registering the string for translation, as it would provide a smoother experience for the client. That said, since the client is unlikely to change the text regularly and it’s probably a one-time change, it shouldn’t be an issue.

    Thanks for your prompt fix, and sorry for my late answer!

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