• Hi there,

    I followed this advice but well PL isn’t WMPL though I hoped it work that way too.
    https://wpml.org/forums/topic/translate-text-added-through-functions-php/

    I added a notice into the checkout which I would like to translate but it doesn’t appear in the string section. So without a rescan I’m clueless what I can do. This is what I got in there. Any hint would be great.

    add_action('woocommerce_review_order_before_payment', 'add_note_to_woocommerce_checkout', );
    function add_note_to_woocommerce_checkout(){ ?>
    	<div class="checkout-note"><h6><?php _e('Bitte beachte die Paypal Zahlung ist nur als Versand mit Sendverfolgung m?glich.', 'textdomain'); ?></h6></div>
    <?php }
Viewing 1 replies (of 1 total)
  • Thread Starter mike8040

    (@mike8040)

    Argh, I couldn’t edit the post. In the meantime I added this code and the string appears in the string section but however it doesn’t get translated. I’m on the right path?

    add_action('init', function() {
        pll_register_string('add_note_to_woocommerce_checkout', 'Bitte beachte die Paypal Zahlung ist nur als Versand mit Sendverfolgung m?glich.');
      });

    ///EDIT: Ok the solution was to use a echo again and rewriting . pll__

    add_action('woocommerce_review_order_before_payment', 'add_note_to_woocommerce_checkout', );
    function add_note_to_woocommerce_checkout(){ 
        echo '<div class="checkout-note"><h6>'  . pll__('Bitte beachte die Paypal Zahlung ist nur als Versand mit Sendverfolgung m?glich.') . '</h6></div>';
      }

    Source:
    https://stackoverflow.com/questions/59863768/cant-translate-string-in-functions-php-using-polylang-wordpress-plugin

    • This reply was modified 3 years, 6 months ago by mike8040.
Viewing 1 replies (of 1 total)
  • The topic ‘Translate string in function.php like in Wpml?’ is closed to new replies.