Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active October 29, 2018 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/40b0ee35ac6841f0153498305ad4888c to your computer and use it in GitHub Desktop.
Save Pebblo/40b0ee35ac6841f0153498305ad4888c to your computer and use it in GitHub Desktop.
Translate some message strings for the EE4 Multi Event Registration add-on.
<?php
// **Please do NOT include the opening php tag, except of course if you're starting with a blank file**
/*
function mer_filter_ngettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
// singular
'1 item was successfully added for this event.'
=> 'There is currently 1 ticket in your basket.',
// plural
'%1$s items were successfully added for this event.'
=> '%1$s tickets were added to your basket.',
);
// 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( 'ngettext', 'mer_filter_ngettext', 11, 3 );
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment