Yeah, it can be frustrating to change some strings.
I’m not sure why you’re having trouble with the .mo approach.
For one or two changes, you can use a function in your theme/functions.php or in bp-custom.php
Try this:
function example_gettext_with_context( $translated, $text, $context, $domain ) {
if ( 'buddypress' !== $domain )
return $translated;
switch ( $text ) {
case 'Site-Wide Activity':
return 'text you want to appear instead';
default:
return $translated;
}
return $translated;
}
add_filter( 'gettext_with_context', 'example_gettext_with_context', 11, 4 );
thanks for the reply
so the lines that say
case ‘Site-Wide Activity’:
return ‘Using gettext_with_context filter’;
i could change to
case ‘Whats Happening?’:
return ‘Using gettext_with_context filter’;
hi @gnfb,
Basic PHP explanation.
A case is the original context. This means while using a switch, if the function encounter the case ‘Side wide activity’, it return ‘Something’.
If you switch to another case, for ex. ‘Groups’, itreturn ‘Bands’.
And finally, if it find no case, it use the default variable $translated.
So in the snippet you use:
case 'Site-Wide Activity': // used by default by BP
return 'Whats Happening?'; // the wording you want to use instead
Hope to be clear.
Thanks Shanebp and danbp – this worked for me, you guys rock!
This finally translated ‘Groups’ and ‘Members’ on my site as well with just two more ‘cases’ in the code:
function example_gettext_with_context( $translated, $text, $context, $domain ) {
if ( 'buddypress' !== $domain )
return $translated;
switch ( $text ) {
case 'Site-Wide Activity':
return 'Historikeraktivitet';
case 'Groups':
return 'Arbejdsgrupper';
case 'Members':
return 'Medlemmer';
default:
return $translated;
}
return $translated;
}
add_filter( 'gettext_with_context', 'example_gettext_with_context', 11, 4 );