bbPress’ language folder (wp-content/plugins/bbpress/bbp-languages) has that warning:

/**
 * Do not put custom translations here. They will be deleted on bbPress updates.
 *
 * Keep custom bbPress translations in /wp-content/languages/
 */

Actually, this is not a new problem and yes, they are right. This is a big problem if you are using WordPress plugins with a non-English language.

Basically, I translated bbPress and created .po and .mo files. Files are working if I put them in their normal wp-content/plugins/bbpress/bbp-languages folder. But as the above warning says, they will delete on update. But the problem is translations are not working if I put them in the wp-content/languages/ folder as suggested in bbPress.

I think there must be a hook or something I can activate it but what is the best solution for it? Simply I want to keep plugin language files in wp-content/languages/.

4 s
4

You have to replace the call to BBpress’ language file.

A good place to do this is a language specific file in your general languages directory. For Turkish it would probably be a file named tr_TR.php. This will be loaded automatically and only if it matches the language of your blog. It will not be overwritten.

BBPress doesn’t use the function load_plugin_textdomain, it uses load_textdomain instead. Here you can find a filter:

$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );

So in your language php file just add a filter to change the path:

function load_bbpress_tr_mofile( $mofile, $domain )
{
    if ( 'bbpress' == $domain )
    {
        // replace this. :)
        return 'FULL_PATH_TO_YOUR_FILE';
    }
    return $mofile;
}
add_filter( 'load_textdomain_mofile', 'load_bbpress_tr_mofile', 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *