1

Good Morning,

I use Events Calendar for our Website, now I want to change the "Now onwards" and "onwards" on top of the page, also the next and previous at the bottom of the event calendar. I already tried to change it with their documentation (and support) but it didn't work. As we are a German business without English business Connections we don't want to have some English text on our page.. Thank you in advance.

1

The "Now onwards" string is translated with _x() which is different than __() because it allows context to be added to the string being translated.

Because there is context, you need to use gettext_with_context instead of gettext. Here's a simple example based on the one in the WP.org Code Reference:

function example_gettext_with_context( $translated, $text ) {
        if ( 'Now' == $text ) {
              $translated = 'Today';
         }

   return $translated;
}
add_filter( 'gettext_with_context', 'example_gettext_with_context', 10, 2 );

You can find the relavent code in the Events Calendar plugin here and here

The Events Calendar website also has some detailed examples.

0

For only a couple of words I would use the gettext filter e.g.

function wse_text_filter( $translated_text, $untranslated_text ) {
    switch( $untranslated_text ) {

        case 'Now onwards':
          $translated_text = __( 'Now backwards','text_domain' );
        break;

        case 'onwards':
          $translated_text = __( 'Backwards','text_domain' );
        break;

   }
   return $translated_text;
}
add_filter('gettext', 'wse_text_filter', 20, 3);

It's hopefully pretty self explanatory, you could also try language switching plugins such as Polyang or WPML.

1
  • Hi, so I inserted this into the functions.php of our website, but it still shows the Now onwards. Am I doing something wrong? Feb 21 '20 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.