Title: Translate strings with Polylang
Last modified: September 21, 2019

---

# Translate strings with Polylang

 *  Resolved [Manuel Camargo](https://wordpress.org/support/users/sirlouen/)
 * (@sirlouen)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/)
 * How it is possible with Polylang, to translate several strings in the plugin 
   for example, the text for the Offline Donation?
 * Example strings that cannot be translated with Polylang:
 * > [View post on imgur.com](https://imgur.com/sdPfEWV)
    -  This topic was modified 6 years, 7 months ago by [Manuel Camargo](https://wordpress.org/support/users/sirlouen/).

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

 *  [gsamsmith](https://wordpress.org/support/users/gsamsmith/)
 * (@gsamsmith)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-11960558)
 * Hi there,
 * While I don’t have experience with the Polylang plugin in particular, we’ve actually
   written an article on translating Give here:
    [https://givewp.com/documentation/resources/translating-give/](https://givewp.com/documentation/resources/translating-give/)
 * This provides a high-level overview of how translations work in both WordPress
   and Give.
 * As for changing strings of text throughout the Give plugin manually if needed,
   we do have a code snippet that can do this for you. Here’s the link to that snippet:
   
   [https://github.com/impress-org/givewp-snippet-library/blob/master/translation-snippets/simple-translation-snippet.php](https://github.com/impress-org/givewp-snippet-library/blob/master/translation-snippets/simple-translation-snippet.php)
 * If you need assistance implementing custom code on your website we have this 
   guide:
    [https://givewp.com/documentation/resources/adding-custom-functions-to-your-wordpress-website/](https://givewp.com/documentation/resources/adding-custom-functions-to-your-wordpress-website/)
 * Please note that this code snippet is provided as an example of how you can extend
   Give with code. It’s up to you to implement and customize to your liking. We 
   cannot provide support for custom code on your website, only the code that we
   create and distribute.
 * ​We also recommend you first make these changes on a staging site or local development
   environment before running this on your live site, to make sure everything goes
   smoothly.
 * Have a great rest of your day!
 *  Thread Starter [Manuel Camargo](https://wordpress.org/support/users/sirlouen/)
 * (@sirlouen)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-11960586)
 * [@gsamsmith](https://wordpress.org/support/users/gsamsmith/) how that code may
   apply for example for the Test Donation label?
    Which domain is? give? give-recurring?
 *  [gsamsmith](https://wordpress.org/support/users/gsamsmith/)
 * (@gsamsmith)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-11963828)
 * Hi there,
 * You’ll need to have the code snippet check for the string “Test Donation” and
   the domain will be “give”.
 * Here’s an example of how that would look:
 *     ```
       function my_give_text_switcher( $translations, $text, $domain ) {
       	// changes the “Donations” text in multiple places
       	if ( $domain == ‘give’ && $text == ’Test Donation ) {
       		$translations = __( ‘YOUR TEXT HERE’, ‘give’ );
       	}
       	return $translations;
       }
       add_filter( ‘gettext’, ‘my_give_text_switcher’, 10, 3 );
       ```
   
 * Thanks!
 *  Thread Starter [Manuel Camargo](https://wordpress.org/support/users/sirlouen/)
 * (@sirlouen)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-11964642)
 * [@gsamsmith](https://wordpress.org/support/users/gsamsmith/) two things:
 * 1. I’ve seen in your Mo files you have the Credit Card string registered
    But
   If I put that String in the field, it should translate automatically to each 
   of the languages that is already translated in the .mo files in the wp-content/
   languages
 * > [View post on imgur.com](https://imgur.com/uqde41Z)
 * But it doesn’t translate. I feel that content in fields, cannot be simply translated.
   So the Label, cannot be translated the way it is designed in Give.
 * 2. A possible solution would be, by integrating the field with the polylang string
   functions
    [https://polylang.pro/doc/function-reference/#pll_register_string](https://polylang.pro/doc/function-reference/#pll_register_string)
   [https://stackoverflow.com/questions/46557981/polylang-how-to-translate-custom-strings](https://stackoverflow.com/questions/46557981/polylang-how-to-translate-custom-strings)
 * So essentially the core elements (what is shown and is not modifiable) can be
   translated in Give, but not the rest which makes Give untrully internationalized
 * A possible easier solution, is to stick the Gateway label to the label as a fixed
   String and use the WordPress internationalization functions. The “Label” thing
   is a good idea, for those who don’t pretend to internationalize. But if you want
   to go next level, Polylang and/or WPML functions shall be introduced.
 * Solved: If you simply delete the label, then the label in place is translated…
   
   BTW it would be great anyway to integrate this label inputs with translation 
   solutions.
    -  This reply was modified 6 years, 7 months ago by [Manuel Camargo](https://wordpress.org/support/users/sirlouen/).
    -  This reply was modified 6 years, 7 months ago by [Manuel Camargo](https://wordpress.org/support/users/sirlouen/).
    -  This reply was modified 6 years, 7 months ago by [Manuel Camargo](https://wordpress.org/support/users/sirlouen/).
 *  Thread Starter [Manuel Camargo](https://wordpress.org/support/users/sirlouen/)
 * (@sirlouen)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-11965141)
 * Translations are not being done adequately, the labels are not being translated
 * Here is a donation form
 * > [View post on imgur.com](https://imgur.com/TZThKx8)
 * As one can see there are three payment options
    1. Test Donation 2. Offline Donation
   3. Tarjeta de Crédito
 * The Credit Card (Tarjeta de Credito) is adquately translated with the .po file,
   but the other two, are not
 * As it can be seen here, any of the 3 labels are filled
 * > [View post on imgur.com](https://imgur.com/10efyt0)
 * Meaning that is not well developed the translation of fields for Test Donation
   and Offline Donation which are in
 * includes/class-give-cache-setting.php
 * Folder (the strings)
 * Shall I report this issue in the github?
    [https://github.com/impress-org/givewp](https://github.com/impress-org/givewp)
 *  [gsamsmith](https://wordpress.org/support/users/gsamsmith/)
 * (@gsamsmith)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-12017685)
 * Hi there,
 * I just confirmed this code snippet translates both the Test Donation and the 
   Offline Donation gateways. Feel free to use this:
 *     ```
       /**
        * A local translation snippet. Change 'YOUR TEXT HERE' to your desired text.
        *
        * @param $translations
        * @param $text
        * @param $domain
        *
        * @return string
        */
       function my_give_two_text_switcher($translations, $text, $domain)
       {
         // changes the "Donations" text in multiple places
         if ($domain == 'give' && $text == 'Test Donation') {
           $translations = __('YOUR TEXT HERE', 'give');
         }
         return $translations;
       }
       add_filter('gettext', 'my_give_two_text_switcher', 10, 3);
   
       function my_give_three_text_switcher($translations, $text, $domain)
       {
         // changes the "Donations" text in multiple places
         if ($domain == 'give' && $text == 'Offline Donation') {
           $translations = __('YOUR TEXT HERE', 'give');
         }
         return $translations;
       }
       add_filter('gettext', 'my_give_three_text_switcher', 10, 3);
       ```
   
 * All you’ll need to do is change the “YOUR TEXT HERE” to whatever you wish.
 * Thanks.
 *  Thread Starter [Manuel Camargo](https://wordpress.org/support/users/sirlouen/)
 * (@sirlouen)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-12020911)
 * Tested but nothing
 * Code in the functions.php
 * > [View post on imgur.com](https://imgur.com/7ol6Nys)
 * Result:
 * > [View post on imgur.com](https://imgur.com/nwjfY6a)
 * Exactly the same text for that given string.
 * By the way, I’ve tried that exact snippet of code with Credit Card string, and
   it works fine.
 *  [gsamsmith](https://wordpress.org/support/users/gsamsmith/)
 * (@gsamsmith)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-12039611)
 * Hi there,
 * I replicated the same issue when attempting to load the function in the theme’s
   functions.php file. Here is a guide for implementing custom code on your site:
 * [https://givewp.com/documentation/resources/adding-custom-functions-to-your-wordpress-website/](https://givewp.com/documentation/resources/adding-custom-functions-to-your-wordpress-website/)
 * When I used the “functionality plugin” method, everything loaded properly.
    -  This reply was modified 6 years, 6 months ago by [gsamsmith](https://wordpress.org/support/users/gsamsmith/).
 *  [gsamsmith](https://wordpress.org/support/users/gsamsmith/)
 * (@gsamsmith)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-12054582)
 * Hi there,
 * I’m going to mark this ticket as resolved, but if there is anything else you 
   need don’t hesitate to reach out.
 * Thanks.

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

The topic ‘Translate strings with Polylang’ is closed to new replies.

 * ![](https://ps.w.org/give/assets/icon-256x256.jpg?rev=2873287)
 * [GiveWP - Donation Plugin and Fundraising Platform](https://wordpress.org/plugins/give/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/give/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/give/)
 * [Active Topics](https://wordpress.org/support/plugin/give/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/give/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/give/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [gsamsmith](https://wordpress.org/support/users/gsamsmith/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/translate-strings-with-polylang/#post-12054582)
 * Status: resolved