Do you want to change various labels and messages in BuddyPress, but don’t want to hack the core files to do so? This page explains how to use a language translation file to customize BuddyPress labels, messages, and URL slugs.
Note: This is not intended for full language translations. If you intend BuddyPress to be used in a language other than English, see the Language Translations page.
Why use a language file?
The most compelling reason to use this method of changing labels and messages is to avoid hand-changing labels and messages in plugin and theme files. Even though theme customizations are recommended and encouraged, it is nice to have your customizations in one place. Overall, creating a custom language file is a better long-term solution than hand-changing plugin or theme files since you can make changes in one place for all labels and messages used in BuddyPress. (Note on upgrading: if you use the automatic upgrade method to update BuddyPress, be aware that your custom language files will be removed.)
Labels and Messages
Here are the steps to create your own custom messages and labels without doing a full language translation. This example uses mysite as the sample language definition; you’ll need to replace it with your own custom definition (make it whatever you want).
1. Create a customized PO file
Open the POT file from the bp-languages folder in your BuddyPress install, copy it to a PO file (by renaming it to have a .po extension). Then make the changes you want in a text editor. Although you can search and replace to make changes, make sure that you are not editing msgid entries. Your custom text goes into the lines labeled msgstr only. For each customization you’ll need to enter your customized text between the quotes on the msgstr line.
For example, to changing the label “Group Wire” to “Group Wall”, you’d look through the PO file until you find line 3502:
#: bp-themes/buddypress-member/groups/group-home.php:62 #: bp-themes/buddypress-member/groups/wire.php:26 msgid "Group Wire" msgstr "Group Wall"
2. Upload the PO file and create the MO file
Move the PO file to wp-content/plugins/buddypress/bp-languages on your server. Then, run the following command from the command line in the same directory. This will create the MO version of the language file.
msgfmt -o buddypress-mysite.mo buddypress-mysite.po
Note: running this command requires command line access to your server via a program like PuTTY (Windows), Terminal.app (Mac), or from inside an FTP program and requires that your server support the GNU gettext command msgfmt. If this is over your head (or you don’t know how to run commands like this, please see Translating WordPress for other software options for converting language files).
3. Load the MO language file with bp-custom.php
In your custom BuddyPress file (wp-content/plugins/bp-custom.php), add a custom language definition to load the language file.
define( 'BPLANG', 'mysite' );
if ( file_exists( BP_PLUGIN_DIR . '/bp-languages/buddypress-' . BPLANG . '.mo' ) ) {
load_textdomain( 'buddypress', BP_PLUGIN_DIR . '/bp-languages/buddypress-' . BPLANG . '.mo' );
}
You’ll notice that this is exactly how bp-core.php would load a site-wide language translation file. We’re doing the same thing here, but without changing the default language and locale (English).
4. Test and verify your changes by loading BuddyPress.
Slugs
You can also change BuddyPress URL slugs (e.g. example.com/members). To change the default slugs to something else, enter your custom slug definitions in your bp-custom.php file (these definitions can also go in your wp-config.php file).
For example, if you are running a sports website with BuddyPress, you could rename the URL slug example.com/members to example.com/players by adding the following line:
define( 'BP_MEMBERS_SLUG', 'players' );
The full list of slugs you can modify can be seen in bp-core.php.
Notes
This is not intended for full language translations. If you intend BuddyPress to be used in a language other than English, see the Language Translations page.
This solution is arguably better than using the define ( 'WPLANG', ''); declaration in your wp-config.php file since we are really just trying to customize BuddyPress and not WordPress MU as a whole.
This page was inspired by a forum topic on BuddyPress.org called I want to speak Spotlish. View that thread for discussion and other suggestions.