MEC | Change Text

Hi,

i need to swap Text “Download Invoice” to “Download Receipt”

in functions.php i use:

add_filter( ‘gettext’, ‘change_mec_text’, 20, 3 );
function change_mec_text( $translated_text, $text, $domain ) {
return is_singular(‘mec-events’) && ( $text ==‘Hourly Schedule’ || $translated_text == ‘Veranstaltung buchen’ ) ? ‘Teilnahme buchen’: $translated_text;}

for another swap, when i try to add something else, its not working. Maybe i am too tired now…?!

Please gibe me a little help :slight_smile:

Thanks,
Cy

Hi Cy,

You can use the following format. That way, it will be easy for you to add another text to swap

add_filter( 'gettext', 'change_mec_text', 20, 3 );

function change_mec_text( $translated_text, $text, $domain ) {
  if(is_singular('mec-events')) {
        switch ( $translated_text ) {

            case 'Download Invoice' :

                $translated_text = 'Download Receipt';

                break;

            case 'Hourly Schedule' :

                $translated_text = 'Stundenplan';
                
                break;

             case 'Another text' :

                $translated_text = 'Your translated text';
                
                break;
        }
  }

    return $translated_text;
}

Please change the text accordingly.

Hope that helps

Thank you, Paul! No, no swap, its still “Download Invoice”…

cy.

Hi Cy,

Can you provide us the url of the page where that text is located.

Thanks

see secure note above…

Hi @cyrock,

That string is used by many different section, some are served through ajax request so the condition if(is_singular('mec-events')) may return false. Please try changing that code to this

add_filter( 'gettext', 'change_mec_text', 20, 3 );

function change_mec_text( $translated_text, $text, $domain ) {
  if( $domain == 'mec' ) {
        switch ( $translated_text ) {

            case 'Download Invoice' :

                $translated_text = 'Download Receipt';

                break;

            case 'Hourly Schedule' :

                $translated_text = 'Stundenplan';
                
                break;

             case 'Another text' :

                $translated_text = 'Your translated text';
                
                break;
        }
  }

    return $translated_text;
}

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.