Viewing 9 replies - 1 through 9 (of 9 total)
  • 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/

    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

    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/

    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

    (@sirlouen)

    @gsamsmith how that code may apply for example for the Test Donation label?
    Which domain is? give? give-recurring?

    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

    (@sirlouen)

    @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

    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://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.

    Thread Starter Manuel Camargo

    (@sirlouen)

    Translations are not being done adequately, the labels are not being translated

    Here is a donation form

    View post on imgur.com

    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

    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

    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

    (@sirlouen)

    Tested but nothing

    Code in the functions.php

    View post on imgur.com

    Result:

    View post on imgur.com

    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.

    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/

    When I used the “functionality plugin” method, everything loaded properly.

    • This reply was modified 6 years, 6 months ago by gsamsmith.

    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.