0

I am ruing multisite, and I have two sites, and the two sites are sharing two plugins, pro and free; I have translated the two plugins on the first site.

And I want to edit a few strings on the second site; when I do that, the string change on the first site and vice versa.

How can I have two translation files with the same language, and each site has its own translation file?

the bottom line: i want to make each site has it own translation not sharing the same translation.

i am using Loco Translate

1 Answer 1

0

If this is just your own personal project with plugins you developed and they plugin won't be more widely distributed, you could just put subdirectories inside the languages directory that correspond to the site ID and load them conditionally:

function myplugin_load_textdomain() {

    $current_site_id = get_current_blog_id();
    
    load_plugin_textdomain( 'myplugin', false, basename( dirname( __FILE__ ) ) . '/languages/' . $current_site_id . '/' );
}
add_action( 'init', 'myplugin_load_textdomain' );

So /languages/1 would be for the main site, and /languages/2 would be for the subsite.

If the plugin will be distributed, you could perhaps add however many sets of translations you want and then add a plugin settings page where the user/you can choose which translation the site uses from a drop-down.

Or, if these are not your own plugins, then this may help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.