• Resolved thefrenchcandlecompany

    (@thefrenchcandlecompany)


    Hi there,

    I’d like to override the text displayed by default as “Subscribe to our newsletter” with a translated version when the viewing language is French. I do this elsewhere on other plugins, I see you have a hook “ss_wc_mailchimp_before_opt_in_checkbox” but am unable to get this to work as I can find the arguments coming in or what to return back.

    Do you have an example I could use as a base for what I need to do?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter thefrenchcandlecompany

    (@thefrenchcandlecompany)

    Hi.

    I have eventually resolved this. For others this was my approach, may not be the best way but I’m not PHP expert.

    I registered a string with Polylang as follows then set the translation in their config screen:

    pll_register_string(‘subscribe-message’,’Subscribe to our newsletter’, ‘woocommerce-mailchimp’, $multiline = false);

    As I cannot simply reference a lable I had to do a string replace on the whole options field variable as :

    add_filter( ‘ss_wc_mailchimp_opt_in_checkbox’ , ‘ss_wc_mailchimp_before_opt_in_checkbox’, 10 , 1 );

    function ss_wc_mailchimp_before_opt_in_checkbox( $opt_in_label ) {
    if ( function_exists( ‘pll__’ ) ) {
    $mylanguage = get_bloginfo(“language”);

    if($mylanguage == “fr-FR”){
    $opt_in_label = str_replace(‘Subscribe to our newsletter’, pll__(‘Subscribe to our newsletter’), $opt_in_label);
    }
    }
    return $opt_in_label;
    }

    It would’ve been nice to simply reference the label text as a variable or array field rather than use the full English as I have had to here.

Viewing 1 replies (of 1 total)
  • The topic ‘Override “Subscribe to our newsletter” text’ is closed to new replies.