Support

Home Forums Event Espresso Premium How to change Text Add More Attendees Click to Toggle using Quick Localisation

How to change Text Add More Attendees Click to Toggle using Quick Localisation

Posted: April 29, 2014 at 4:43 am


Jason Scarff

April 29, 2014 at 4:43 am

WP V3.9 EE V3.1
http://www.mullingarequestrian.com/show/?page_id=7&ee=1

Hi I would like to change the text “Add More Attendees (Click to Toggle, Limit_) in Quick Localistion. What is Old Text to use?


Dean

April 29, 2014 at 5:46 am

Hi,

Add More Attendees? (click to toggle, limit %s)


Jason Scarff

April 29, 2014 at 8:54 am

Many thanks, Much appreciated.
J


Jason Scarff

April 29, 2014 at 10:27 am

Hi I just want to change the text “Attendee” on both lines on the attach screen shot


Jason Scarff

April 29, 2014 at 10:30 am

Can’t add the screen shot. this is the link to the checkout page!
http://www.mullingarequestrian.com/show/?page_id=7&regevent_action=load_checkout_page


Jason Scarff

April 29, 2014 at 10:31 am

IMAGE LINK for the screen shot
http://mullingarequestrian.com/screenshot-show.JPG


Lorenzo Orlando Caum

  • Support Staff

April 30, 2014 at 11:56 am

Hi Jason,

I see “Attendee 1” in that screenshot. What would you like to change it to?


Lorenzo


Jason Scarff

May 1, 2014 at 4:13 am

I would to change it to Entry 1 and above this as well is x 1 attendee I would like to change to x 1 entry

Thanks


Dean

May 1, 2014 at 6:36 am

Hi,

For the Attendee 1, simply use “Attendee ” (without the quotes BUT with the space!)

The 1 attendee (or 2 attendees, etc) is a little harder. With the translation files it finds it easily enough.

Basically it is %d attendee or %d attendees

However it is using _n function. If you look at the _n function on WP.org codex (https://codex.wordpress.org/Function_Reference/_n) it says that it uses the ngettext filter.

As far as I am aware, Quick Localisation doesn’t use this filter so it can’t find the string to translate.

From the Quick Localisation page on WP.org:

“Quick Localisation allows to hook on gettext so that one can easily tweak WordPress translations generated by functions __ and _e.”

It does not mention _n so I cant see how you can use the plugin to translate those strings.

However, you could drop this modified gettext function into your themes functions.php (or a separate plugin) and it should do the trick

function youruniqueprefix_filter_gettext( $translated, $original, $domain ) {
 
    $strings = array(
		'%d attendee'     => ' %d Entry',
                '%d attendees'     => ' %d Entries'
        // Add some more strings here
    );
 
    if ( isset( $strings[$original] ) ) {
        $translations = &get_translations_for_domain( $domain );
        $translated = $translations->translate( $strings[$original] );
    }
 
    return $translated;
}
 
add_filter( 'ngettext', 'youruniqueprefix_filter_gettext', 10, 3 );


Jason Scarff

May 1, 2014 at 8:24 am

Thank you that has worked, but the plural is coming up single. i.e. x2 Attendees = x2 Entry


Dean

May 1, 2014 at 8:57 am

Hi Jason,

OK, I merely assumed that would work, so my apologies.

Talking to a developer on this, it looks like the main sprintf is wrong (I’ve raised a ticket to look into that), plus the function was still not right as it was basing it on the normal gettext.

So, to fix this you will need to 1) edit a file and 2) update the function.

1) In the multi_registration_page_display.php template file, near the top is the following line:

$attendee_quantity = ' x '.sprintf(_n('%d attendee', '%d attendees', $meta['attendee_quantity'], 'event_espresso'), $meta['attendee_quantity']);

Replace it with

$qty = (int) $meta['attendee_quantity'];
$attendee_quantity = ' x '.sprintf( _n('1 attendee', '%d attendees', $qty, 'event_espresso'), $qty );

2) Use the following function in your themes functions.php or a separate plugin:

function youruniqueprefix_filter_gettext( $translation, $single, $plural, $number, $domain ) {
 
    $strings = array(
		'1 attendee'     => '1 Entry',
		'%d attendees'     => '%d Entries'
        // Add some more strings here
    );
 
    if ( isset( $strings[$translation] ) ) {
        $translations = &get_translations_for_domain( $domain );
        $translated = $translations->translate( $strings[$translation] );
    }
 
    return $translated;
}
 
add_filter( 'ngettext', 'youruniqueprefix_filter_gettext', 10, 5 );

Let me know how you get on with this.

The support post ‘How to change Text Add More Attendees Click to Toggle using Quick Localisation’ 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