Title: Translate string in function.php like in Wpml?
Last modified: May 25, 2021

---

# Translate string in function.php like in Wpml?

 *  [mike8040](https://wordpress.org/support/users/mike8040/)
 * (@mike8040)
 * [5 years ago](https://wordpress.org/support/topic/translate-string-in-function-php-like-in-wpml/)
 * 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/](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](https://wordpress.org/support/users/mike8040/)
 * (@mike8040)
 * [5 years ago](https://wordpress.org/support/topic/translate-string-in-function-php-like-in-wpml/#post-14482479)
 * 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](https://stackoverflow.com/questions/59863768/cant-translate-string-in-functions-php-using-polylang-wordpress-plugin)
    -  This reply was modified 5 years ago by [mike8040](https://wordpress.org/support/users/mike8040/).

Viewing 1 replies (of 1 total)

The topic ‘Translate string in function.php like in Wpml?’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

## Tags

 * [function.php](https://wordpress.org/support/topic-tag/function-php/)
 * [string](https://wordpress.org/support/topic-tag/string/)

 * 1 reply
 * 1 participant
 * Last reply from: [mike8040](https://wordpress.org/support/users/mike8040/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/translate-string-in-function-php-like-in-wpml/#post-14482479)
 * Status: not resolved