Support

Home Forums Event Espresso Premium [EE4} Another phrase that needs wrapped in translate code

[EE4} Another phrase that needs wrapped in translate code

Posted: February 25, 2014 at 4:34 pm


Chris Stambaugh

February 25, 2014 at 4:34 pm

Hi,

I am trying to use the Check payment type in EE4 for a system we have in Canada called Interac E-Transfer which allows bank clients to basically email funds to another user.

When a user selects this payment method right now, right at the end of the transaction where they are receiving the instructions on how to pay, they receive this message:

“After finalizing your registration, you will be transferred to the payment overview where you can view details of how to complete your payment by Check.”

Instead, I’d like that to read as:

After finalizing your registration, you will be transferred to the payment overview where you can view details of how to complete your payment by Interac e-Transfer.”

Please and thank you???

Paul


Dean

February 26, 2014 at 12:28 am

Hi Paul,

I checked the latest EE4 release and that phrase is ready for translation.

If the phrase is not currently in the translation files, you could use the gettext filter, as outlined here http://www.viper007bond.com/2011/07/13/changing-core-wordpress-strings/


Chris Stambaugh

February 27, 2014 at 8:24 am

Dean,

I’m using the gettext filter and it isn’t working.

How can I make the change via translation?

Paul


Josh

  • Support Staff

February 27, 2014 at 9:06 am

Hi Paul,

Can you post the line of code where that’s not translating so we can take a look?


Chris Stambaugh

February 27, 2014 at 1:52 pm

Josh,

Not sure what you mean by the line of code? Line of code from where?

I have a string in the array in the mycustom_filter_gettext function that looks like this:

‘Check.’, “Interac Email Transfer.’,

But, “Check.” does not get changed at all.

Paul


Dean

February 28, 2014 at 12:59 am

Hi,

That isn’t quite how string translation works, it needs to be the full string, not a partial.

This should do the trick

function youruniqueprefix_filter_gettext( $translated, $original, $domain ) {
 
    // This is an array of original strings
    // and what they should be replaced with
    $strings = array(
        'After finalizing your registration, you will be transferred to the payment overview where you can view details of how to complete your payment by Check.' => 'After finalizing your registration, you will be transferred to the payment overview where you can view details of how to complete your payment by Cheque.',
        // Add some more strings here
    );
 
    // See if the current string is in the $strings array
    // If so, replace it's translation
    if ( isset( $strings[$original] ) ) {
        // This accomplishes the same thing as __()
        // but without running it through the filter again
        $translations = &get_translations_for_domain( $domain );
        $translated = $translations->translate( $strings[$original] );
    }
 
    return $translated;
}
 
add_filter( 'gettext', 'youruniqueprefix_filter_gettext', 10, 3 );


Chris Stambaugh

February 28, 2014 at 7:50 am

That worked! Thanks.

The support post ‘[EE4} Another phrase that needs wrapped in translate code’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso