Title: Translate string in functions.php
Last modified: February 11, 2018

---

# Translate string in functions.php

 *  [dawed78](https://wordpress.org/support/users/dawed78/)
 * (@dawed78)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/)
 * Hello
    How to translate a string from custom code in functions.php. of child 
   theme? Thanks Greetings Davide

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [catheg](https://wordpress.org/support/users/catheg/)
 * (@catheg)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/#post-9973772)
 * Hello,
 * For example in you want to translate the string ‘Tous droits réservés’ in french
   to “All rights reserved’ in English in your footer.
 * In functions.php code :
    if (function_exists(‘pll_register_string’)) { pll_register_string(‘
   Footer’, ‘Tous droits réservés’); }
 * In footer.php code
    <?php if (function_exists(‘pll__’)) echo pll__(‘Tous droits
   réservés’); ?>
 * Now you can translate the string ‘Tous droits réservés’ in Language/String translation
   in the WP dashboard.
 * Catherine.
 *  Thread Starter [dawed78](https://wordpress.org/support/users/dawed78/)
 * (@dawed78)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/#post-9974233)
 * Hello
    That work! But I need to translate my snippet code added in functions.
   php, for example customize woocommerce, like:
 * function function bbloomer_display_sold_out_loop_woocommerce() {
    global $product;
 *  if ( !$product->is_in_stock() ) {
    echo ‘<span class=”soldout”>’ . __(‘VENDUTA’,‘
   woocommerce’) . ‘</span>’; } } add_action( ‘woocommerce_before_single_product_summary’,
   function() { globaL $product; if ( !$product->is_in_stock() ) { echo ‘<span class
   =”soldout”>VENDUTA</span>’; } });display_sold_out_loop_woocommerce() { global
   $product;
 *  if ( !$product->is_in_stock() ) {
    echo ‘<span class=”soldout”>’ . __(‘VENDUTA’,‘
   woocommerce’) . ‘</span>’; } } add_action( ‘woocommerce_before_single_product_summary’,
   function() { globaL $product; if ( !$product->is_in_stock() ) { echo ‘<span class
   =”soldout”>VENDUTA</span>’; } });
 * I need to translate ‘VENDUTA’ in “SOLD OUT” for english version
 * Thanks
 *  [catheg](https://wordpress.org/support/users/catheg/)
 * (@catheg)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/#post-9974377)
 * It seems that you have the string VENDUTA internationalized with __() in your
   code. So you can translate it with po/mo files.
 * Add or edit with the poedit tool the English translation po file of woocommerce
   and see if you find the VENDUTA string and translate into SOLD OUT
 *  Thread Starter [dawed78](https://wordpress.org/support/users/dawed78/)
 * (@dawed78)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/#post-9974488)
 * I do not find it … that string VENDUTA was added by me in functions.php.
    I Have
   added you code but that string do not appear in language / string translation...
   Maybe I need to add: echo pll_ in functions.php?
 *  [catheg](https://wordpress.org/support/users/catheg/)
 * (@catheg)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/#post-9974596)
 * Maybe. Try this :
 * Register VENDUTA string
    if (function_exists(‘pll_register_string’)) pll_register_string(‘
   mysnipet’, ‘VENDUTA’);
 *  translate the string ‘VENDUTA’ by ‘SOLD OUT’in Language/String translation in
   the WP dashboard.
 * replace in your code __(‘VENDUTA’, ‘woocommerce’) by if (function_exists(‘pll__’))
   echo pll__(‘VENDUTA’);
 *  Thread Starter [dawed78](https://wordpress.org/support/users/dawed78/)
 * (@dawed78)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/#post-9975353)
 * Ok Thanks
    That work I have just changhe in: __(pll__(‘VENDUTA’), ‘woocommerce’)
   Greetings Davide

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Translate string in functions.php’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [dawed78](https://wordpress.org/support/users/dawed78/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/translate-string-in-functions-php/#post-9975353)
 * Status: not resolved