Tutorial: How to edit or translate words in BuddyPress
-
It’s not that difficult to change words when you know how. I’ll step you through it.
This is what localized text looks like in BuddyPress theme files _e( ‘Home’, ‘buddypress’ ). This allows BuddyPress to be translated into any language just by adding a file. You can also change the names of Groups to something else that better suits your network. Maybe you want teams instead.
What is this localized text?
The first part ‘Home” is the word or string that can be translated or changed. The second part ‘buddypress’ is used to say I want anything with this attached to use this language. WordPress scans through and everywhere ‘buddypress’ is it will swap out the first part with your word from a .mo file.
You need Poedit
http://www.poedit.net/download.php
Download, install and open.
Then you click file and choose – New catalog from pot file.
Search for the buddypress.pot file. You can find it in the buddypress plugin folder inside bp-languages. This file has all the text that can be localized or changed that is located within the BuddyPress default theme. Poedit allows you to scroll through all the text and then change it.Make all your changes by scrolling through list of strings and then adding yours below. When your done hit save. Save your file to something like buddypress-mychanges.po. Poedit will create another file with a .mo extension. This .mo file is actually the file that WordPress will read. It’s a better and faster file that computers can drill through. That way when you load a page the translation is instantaneous.
Finally you upload the files, buddypress-mychanges.po and buddypress-mychanges.mo to the same folder as buddypress.pot was that you first opened.
Ok, now we need to tell BuddyPress to use your custom language file. If you do not have a file called bp-custom.php in your wp-content/plugins folder then add one and then add the following code to it:
<?php
if ( file_exists( WP_PLUGIN_DIR . '/buddypress//bp-languages/buddypress-mychanges.mo' ) ) {load_textdomain( 'buddypress', WP_PLUGIN_DIR . '/buddypress//bp-languages/buddypress-mychanges.mo' );
}
?>
Test your site, you should now see changes. You can easily change future text by opening the buddypress-mychanges.po file and hitting save again. Each time you save it will create a new .mo file that WordPress will read.
Need help? Comment below.
- The topic ‘Tutorial: How to edit or translate words in BuddyPress’ is closed to new replies.