switch_to_blog(): Load textdomain

You could hook into the action switch_blog. You get the new blog ID as the first argument here. But loading the complete translation files here is expensive, you also have to restore the old files after that.

WordPress does not use native gettext functions, but some custom code that is much slower. See #17268. The performance penalty for that would be huge.

Filter the URLs from the plugin instead, in this case mlp_linked_element_link, and use a hard-coded list of replacements like this:

add_filter( 'mlp_linked_element_link', function( $url, $site_id ) {

    if ( 1 === (int) $site_id )
        return str_replace( '/produkt/', '/product/', $url );

    if ( 2 === (int) $site_id )
        return str_replace( '/product/', '/produkt/', $url );

    return $url;

}, 10, 2 );

This is much faster. Permalinks and language file handling is still broken in multisite, you have to live with compromises.

Leave a Comment