there, I'd like to know: when a client wants specific item

Hi there, I’d like to know: when a client wants specific item to be translated in another way than my plugin translation is, can I make a separate translation for this client?

I guess yes, but in what directory should the translation go?

(Client is in my MultiSite install)

Thx in advance for helping!

  • Vaughan
    • Support/SLS MockingJay

    Hi Ronald,

    Hope you’re well?

    It isn’t quite as simple as that unfortunately.

    You can replace the translation file, but that is global through the network.

    However, there might be a possibility using a custom mu-plugin function to unload the translation/text-domain on a specific site only and then tell it to load a different file from another location.

    I have never tried this so it might not work.

    Create a file called blog_translations.php

    In this file add the following code.

    <?php
    function wpmudev_blog_localisation() {
    $current_blog_id = get_current_blog_id();

    $translation_blog_id = 2; // change this to the blog you want to use a different translation on
    $language_filename = 'subscribe-by-email_en_GB.mo';

    if ($current_blog_id == $translation_blog_id) {
    unload_textdomain('subscribe-by-email');

    $translations_dir = wp_upload_dir();
    $translation_path = $translations_dir['baseurl'] . '/sites/' . $current_blog_id . '/languages/';
    $s = load_textdomain('subscribe-by-email', $translation_path . $language_filename);
    }
    }
    add_action('init', 'wpmudev_blog_localisation');

    change $translation_blog_id to the id of the blog you want this to be used on.

    change $language_filename to the filename of your new language file.

    Now go to /wp-content/uploads/sites/x/

    where x = the blog_id.

    create a folder called /languages

    Now upload your translation.mo file to that folder.

    Then upload the blog_translations.php file you just created to the /wp-content/mu-plugins folder.

    Hopefully that should then do as you require. I haven’t tested this tho.

    Hope this helps

  • Ronald
    • The Crimson Coder

    Thx Vaughan, that looks cool!!

    I’m travelling these weeks and have little opportunity to experiment as intensively as I expect to have with this issue, so I “park it” a few weeks and let you know when I have (no) results!

    Cheers!!

  • Ronald
    • The Crimson Coder

    Hi Vaughan,

    I finished travelling, catched up the work and am now ready to try your suggestion.

    Question 1: I don’t have a mu-plugins folder in wp-content; can I put the php file in the plugins folder or should I make the mu-plugins folder?

  • Ronald
    • The Crimson Coder

    Hi Vaughan,

    Well, I created the plugin dir and places the php file in it. (And removed caching for the time being.)

    Uploaded the new translation to blogs.dir/websiteID/languages.

    Something did happen, because most (not all) of the translated terms are now in English. So it looks like the standard nl_NL translation is ‘unloaded’, if that’s the right term.

    But the new translations do not show up.

    Do you have any idea how we continue?

    Thx again, best regards,

    Ronald

  • Ash
    • WordPress Hacker

    Hi @ronald

    Please confirm three points:

    1. Did you set the correct blog ID here?

    $translation_blog_id = 2;

    2. Is the file name correct?

    $language_filename = 'subscribe-by-email_en_GB.mo';

    3. And did you put the file in /wp-content/uploads/sites/THAT SITE ID/languages/ folder?

    Have an awesome day!

    Cheers

    Ash

  • Ash
    • WordPress Hacker

    Hi there

    Thanks for sending details. I could use another language for a specific subsite. In my case, my subsite ID was 25. Please follow the steps:

    1. Rename the mo file to subscribe-by-email-nl_NL.mo

    2. Put the file in /wp-content/uploads/sites/25/languages/subscribe-by-email-nl_NL.mo [here I have used my subsite ID 25]

    3. Use the following code:

    function wpmudev_blog_localisation() {
    $current_blog_id = get_current_blog_id();
    $language_filename = 'subscribe-by-email-nl_NL.mo';
    $translation_blog_id = 25; // My subsite ID is 25

    if ($current_blog_id == $translation_blog_id) {
    unload_textdomain('subscribe-by-email');

    $translations_dir = wp_upload_dir();

    $translation_path = $translations_dir['basedir'] . '/languages/';

    $translation_path . $language_filename;
    $s = load_textdomain('subscribe-by-email', $translation_path . $language_filename);
    }
    }
    add_action('init', 'wpmudev_blog_localisation');

    Now it should work.

    Please give it a try and let me know.

    Have an awesome day!

    Cheers

    Ash

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    blogs.dir is from an older pre wp 3.4 install, so could be it’s getting the wrong paths?

    Have you tried it in your blogs.dir? might be worth a try. if not, Can you send your details using the following contact form (select i have a different question from the dropdown.)

    https://premium.wpmudev.org/contact/

    Mark for attn: Vaughan

    Include a ref URL to this thread.

    Please include the following details;

    – Site login details (super-admin if on multisite)

    – FTP login details so I can take a look at the theme/plugin files.

    We can then try & debug this on the server itself to see what & where it’s actually trying to load from.

    Thanks

  • Vaughan
    • Support/SLS MockingJay

    Hi ronald,

    From the translation path. It’s actually giving me the following location.

    /wp-content/blogs.dir/69/files/languages/

    So you should definitely place your translation file in that folder :slight_smile:

    If you have any cache plugins installed at all, you should clear the cache so that it’s regenerated with the new translation.

    Hope this helps

  • Ronald
    • The Crimson Coder

    All done, Vaughan!

    Even deleted my caching plugin…

    But in the plugin admin area still a mix visible of English and a bit Dutch.

    Did you receive my email?

    You should have superadmin access.

    Thx for helping, I really appreciate it!

  • Vaughan
    • Support/SLS MockingJay

    Hi ronald,

    I’ve taken a look and I’m a little unsure of why it’s doing this in the admin.

    I can certainly see that the function is being triggered in the admin area, but it’s not loading the language file.

    Let me just ask @ashok for some more assistance and see if he can spot something i missed.

    Thanks

  • Ronald
    • The Crimson Coder

    Hi Vaughan and/or Ashok,

    I don’t want to bump, but am very curious at the (lack of?) progress on this item.

    My client starts asking.

    Now it is not a matter of life and dead, so nothing will happen when the problem is not solvable, but then I’d like to know certain so I can finish the task and communicate with the client.

    Thx in advance!

  • Ash
    • WordPress Hacker

    Hi @ronald

    Thank you for your patience.

    I have taken a look at your site. Please check now, screenshot attached. Two sites are loading two different language files.

    Please note that, I have used my changed language file so that I know what the difference is between two files. You need to replace with your file again.

    The language directory for all site is /wp-content/languages/plugins/

    The language directory for site 69 is /wp-content/uploads/sites/69/languages/

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers

    Ash

  • Ronald
    • The Crimson Coder

    Great news!!!

    I am travelling this week, will check, test and respond later, but shall communicate with my client.

    A quick look at the revealed a strange issue with the menu-height, which disappears after removing the file from the dir mu-plugins.

    The css info gives the div#navigation a min-height of 100%, I can’t fix this.

    Can you please look howcome?

    Cheers, really great news!

  • Vaughan
    • Support/SLS MockingJay

    Hi ronald,

    Apologies for the delay. Ash was busy last week & I was off sick. Could you grant support access again, and also put the file back in place :slight_smile: i’ve subscribed to this thread, so will get a notice once you have done so and i’ll take a look at the menu.

    Could you also take a screenshot of the menu before/after, so i know exactly what it should look like, for reference.

    Thanks

  • Ronald
    • The Crimson Coder

    Hi Vaughan,

    I hope you’re better!

    Thanks for responding.

    OK, I granted support access and will add two screenshots, you’ll see immediately…

    BUT also I found two lines in the blogs-translations.php file which, when uncommented, solve the problem, and that are the lines 38 and 39.

    Can you confirm that this was an OK action, and is it then perhaps good to do some cleaning up in the file?

  • Vaughan
    • Support/SLS MockingJay

    Hi Ronald,

    I’m not sure why uncommenting those lines solves the issue with the nav menu.

    all those will do is check if the translation file exists, if it does, then it will print 100 on the screen .

    It is certainly safe to remove all those commented lines though.

    you can remove that min-height from the nav menu though by adding the following to the style.css on that site’s theme.

    Or install the following plugin on that site:

    https://wordpress.org/plugins/wp-add-custom-css/

    Then add the following CSS:

    div#navigation {
    min-height: 20px !important;
    }

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.