Look at the source, you know that already. 🙂
I didn’t but I bet there is a piece of code looking like this:
_e( 'Activity', 'buddypress' );
… or …
__( 'Activity', 'buddypress' );
Follow the functions, they are wrappers for the function translate()
in wp-includes/l10n.php
:
/**
* Retrieves the translation of $text. If there is no translation, or
* the domain isn't loaded, the original text is returned.
*
* @see __() Don't use translate() directly, use __()
* @since 2.2.0
* @uses apply_filters() Calls 'gettext' on domain translated text
* with the untranslated text as second parameter.
*
* @param string $text Text to translate.
* @param string $domain Domain to retrieve the translated text.
* @return string Translated text
*/
function translate( $text, $domain = 'default' ) {
$translations = &get_translations_for_domain( $domain );
return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain );
}
You see you get a filter: 'gettext'
with three arguments (or parameters). Now you can use the filter to change the output.
Add this to your theme’s functions.php
or to a plugin:
add_filter(
'gettext', // filter name
'wpse_57673_change_buddypress_profile_tabs', // name of your custom function
10, // priority
3 // number of arguments you want to get
);
Now we need the custom function, that’s really simple:
function wpse_57673_change_buddypress_profile_tabs( $translated, $original_text, $domain )
{
if ( 'buddypress' !== $domain )
{
return $translated; // not your text
}
// find the text to change
switch ( $original_text )
{
case 'Activity':
return 'My Activity';
case 'Groups':
return 'My Groups';
default:
return $translated;
}
}