How to Change Wording and Text with POedit

It is often useful to be able to change the text or wording of something in Event Espresso in order for it to fit in with your site and audience better. You can hunt through the code to find the strings (text) to replace but there is a much easier and recommended way: use Poedit to change the language files.

What happens is you take the language file (in this example we will work with US English) and translate it, in order to change the text.

1) We recommend downloading and installing Poedit for working on translation files.

2) After you install Poedit, you can download a copy of the event_espresso-en_US.po file from our GlotPress project. Then you can open it in Poedit.

3) Use the Find tool to pull up the text string you need to modify.

4) Change the string as shown:

poedit

5) Save, then upload the newly generated .mo file to the wp-content/uploads/espresso/languages directory on your server.

6) Keep a copy of the modified language files saved somewhere in case you need to re-edit it or re-upload it.

Changing text strings by using a plugin or a custom function

If you know the exact text string you need to re-word, you can alternatively use the Quick Localisation plugin that can be downloaded here for free:

http://wordpress.org/plugins/quick-localization/

Quick Localisation

Or you can add a  custom function to your theme’s functions.php file, the custom_functions.php file that is included with Event Espresso’s Custom Files add-on (EE3 only), or your own custom site specific plugin. Example code follows:

<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file

function mycustom_filter_gettext( $translated, $original, $domain ) {
 
    // This is an array of original strings
    // and what they should be replaced with
    $strings = array(
        'Register' => 'Sign up',
        'Confirm and go to payment page' => 'Complete registration',
        'No events available...' => 'No upcoming classes at this time...',
        'click here to add a new state/province' => 'click here to enter address outside US/Canada',
        // Add some more strings here
    );
 
    // See if the current string is in the $strings array
    // If so, replace its 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', 'mycustom_filter_gettext', 10, 3 );

Visit the row on Git: https://gist.github.com/joshfeck/4962940#file-filter_gettext-php

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us