Kau-Boy’s Backend Localization Plugin

This plugin enables you to run your blog in a different language than the backend of your blog. So you can serve your blog using e.g. German as the default language for the users, but keep English as the language for the administration.

Installation:

Installation trough WordPress admin pages:

  1. Go to the admin page Plugins -> Add New
  2. Search for kau-boy and choose the plugin
  3. Choose the action install
  4. Click on Install now
  5. Activate the plugin after install has finished (with the link or trough the plugin page)
  6. You might have to edit the settings, especially the language you want to use

Installation using WordPress admin pages:

  1. Download the plugin zip file: kau-boys-backend-localization.1.6.zip
  2. Go to the admin page Plugins -> Add New
  3. Choose the Upload link under the Install Plugins headline
  4. Browse for the zip file and click Install Now
  5. Activate the plugin after install has finished (with the link or trough the plugin page)
  6. You might have to edit the settings, especially the language you want to use

Installation using ftp:

  1. Download the plugin zip file: kau-boys-backend-localization.2.0.3.zip
  2. Unzip und upload the files to your /wp-content/plugins/ directory
  3. Activate the plugin through the Plugins menu in WordPress
  4. You might have to edit the settings, especially the language you want to use

Screenshots:

Screenshot of the settings page

Screenshot of the settings page

Screenshot of language switcher in admin menu (similar to qTranslate switcher)

Screenshot of language switcher

Screenshot of language selection on login form

Screenshot of language selection on login form

Change Log:

  • 1.6 Add WP3 CSS class for the language select on the login form
  • 1.5 Fixing the plugin for WordPress 3.0 MULTISITE feature
  • 1.4 Fixing the plugin for WordPress MU and fixing the login form selection
  • 1.3 Make the plugin working with PHP4. Thanks to David for the fix!
  • 1.2.1 Replace the do_action() function with the add_action() function for admin_menu to avoid issues with other plugins
  • 1.2 Adding support for new languages
  • 1.1 Removing “short open tags” which causes error on blog that don’t have “short_open_tag” set to “On”
  • 1.0 Adding language switcher to admin menu and option to hide language selection on login form
  • 0.6 Saving language setting in cookie to enable different languages for multiple users
  • 0.5 Adding language selection to login screen
  • 0.4 Display all languages that are installed in the WordPress language folder
  • 0.3 Activate new language after saving settings (no more need to refresh)
  • 0.2 Adding German translation for settings page
  • 0.1 First stable release

If you like the plugin or if something is missing I would like to here it. Just leave a comment on this page or on my WordPress plugin page.

PayPal - The safer, easier way to pay online! PayPal - The safer, easier way to pay online!

Posted by

Bernhard is a full time web developer who likes to write WordPress plugins in his free time and is an active member of the WP Meetups in Berlin and Potsdam.

64 comments » Write a comment

  1. Hi! Nice PlugIn (i guess) – can’t get it to work on a WordPress MU Blog. Don’t know whether it’s due to that, or if i did something wrong. The following thing happend, when i uploaded the .zip, which has automatically been extracted. The installation has been also successful, but i was unable to activate it. I got the following error:

    ( ! ) Parse error: syntax error, unexpected ‘}’ in /path/to/wp/wp-content/plugins/kau-boys-backend-localization/backend_localization.php on line 167

    Are there any hints you can give me?

    • Thanks for your error reposting. On my new local test environment I once had the same problem. But that it suddenly disappeared, so I thought it was because of a developing error on that local test blog. But now with your help I found the problem. In to lines I used <? in and not <?php to open a PHP block. This so called short open tag must be activated in PHP which isn't in most of the custom setting. I now replaced the two short open tags with the correct long form and added the new version 1.1 to the wordpress plugins. So please update the plugin through your blog backend.

      Again many thanks for finding this error!

  2. Hey Bernhard, thanks for the fast response due to the bug 😉

    At least I have been able to activate your plugin. Now I can see the language switches on the login screen and in the backend. But they do not provide any functionality. Any changes I do are not applied. Only the ‘Blog language’-option in the ‘Settings>Generals’ tab seem to be able changing the language of the backend.
    The only thing I did has been creating a directory ‘languages’ in the ‘wp-content’ dir and putting in the ‘de_DE.mo’ language file and editing the ‘wp-config.php’ line define (‘WPLANG’, ”); to define (‘WPLANG’, ‘de_DE’);. Further info: using WordPress MU 2.8.5.2 .

    Thanks again for any help 😉

    • Plese go to the settings page of my plugin. Can you see any available languages on this page? In the description you will find the path to the folder, where you have to place to .mo files. On most blogs it should be inside the wp_content folder, but it might be in a diffrent one in WordPress MU. Yesterday I tried to install a WordPress MU on my local test environment, but I didn’t succeed. I wil try to do that this evening again to find out if there is a problem with Wordress MU.

      Using my plugin you don’t have to chage the WPLANG in the config. also you shouldn’t change the WPLANG, as it changed both, the backend AND the frontend language.

    • Yes that would be great. I don’t have a current .pot file in the plugins folder but you can just copy the German po file and use it for your translation.

  3. Hey Bernhard,

    I,ve installed your Plug-In and I,m using WordPress 2.8.6. Now I,ve a problem. WordPress shows me the different languages and if I choose one, nothing happen. The backend language is still the same. Could you please help me?

    • How did you tried to change the backend language? In some cases, the selection on the login screen doesn’t work, especially if it is affected by some other plugins. But you should be able to change the language with the switcher in the admin menu.

      • I,ve tried both ways, but it didn,t work. If I change the language in ‘wp-config.php’ (‘WPLANG’, ‘es_ES’); it works. I,m using WPML Multilingual CMS Plug-In for the frontend. May be it is because of WPML?

  4. I like this plug-in but am wondering if you could create a PHP 4 compatable version due to the host I have?

    scandir is causing me some issues. Thanks!

    • I resolved the issue. Some may not be necessary.

      /* php 4 fix */
      $dir = WP_LANG_DIR;
      $dh  = opendir($dir);
      while (false !== ($filename = readdir($dh))) {
      	$files[] = $filename;
      }
      /* read the array */
      foreach($files as $file){
      	$fileParts = pathinfo($file);
      	if(!isset($fileParts['filename']) &amp;&amp; $fileParts['extension'] == 'mo' &amp;&amp; (strlen($fileParts['filename']) &lt;= 5)){
      		$fileParts['filename'] = substr($fileParts['basename'], 0,strpos($fileParts['basename'],'.'));
      		$backend_locale_array[] = $fileParts['filename'];
      	}
      }
      
  5. I’m using this plugin in WPMU installation and it works fine in all the blogs, expect for one. In this one blog, the language selected on the login page’s dropbox comes back once and again. For example, if pick EN when logging in and then I use the flags to change languages, every time I clik on a menu item, the language changes back to EN.

    Any ideas of what the problem could be?

    Thanks a lot!

    • Is this one blog also running on the WPMU system with all the other blogs? Which Version of WPMU do you use. I am going to get a setup like yours to reproduce the problem.

  6. Hallo,

    ich nutze das Plugin in einer Wpmu Installation.
    Ich habe als Sprachze für das Backend Deutsch gewählt.
    Allerdings ist noch immer alles in Englisch.
    Woran könnte das liegen?

    Grüße,
    Lars

    • Hallo Lars,

      das gleiche Problem hat auch Inaki angesprochen. Ich bin noch dabei rauszufinden woran es liegt. Nutzt du auch WPMU 2.9.2?

      Gruß
      Bernhard

    • Ok, ich installiere mir dann jetzt gleich mal WPMU 2.9.2 und werde versuchen den Fehler so schnell wie möglich zu finden.

      • ja lässig, gib Bescheid, wenn du was genaueres weißt.
        Bei den Plugins scheint es übrigens zu funktionieren sofern diese mehrsprachig sind.

  7. Pingback: Backend Localization Plugin für WordPress MU repariert « Kau-Boys blog

  8. @Inaki: The Plugin has been fixed for WordPress MU. Thanks for your comment.
    @Lars: Danke auch für deinen Kommentar und ich hoffe es funktioniert jetzt bei dir.

  9. Hi, I’ve tried the plugin with WordPress 3 MS. It changes the backend language without any problems but…but.. it prevents the frontend language from being changed. I’ve tried network activation, activation per site and activation only on the top domain but the result is always the same – the backend language changes but the frontend (regardless of WPLANG) remains in English (the plugin’s default backend language).

    I might have misunderstood the plugins purpose, is it supposed to change the backend language and allow the frontend language to be whatever is set in WP-Lang?

    • The plugin should only change the backend language. Maybe there is an error in your wp-config.php. Have you tried to change the value of WPLANG to something diffrent and than deactivate my plugin. Does it work doing so?

      The only request parameters that should trigger the language to change are “pwd” and “kau-boys_backend_localization_language” and the defined variable WP_ADMIN which should only be set in the backend.

      Who does the WP_LANG value in your wp-config.php looks like? Do you use a multilingual theme with the correct language files installed. I would be glad if I can help you out.

      • Thank you for your quick reply.

        WPLANG in confi.php is set toits default parameter:

        define (‘WPLANG’, ”);

        The only place I’ve set each sites language is via Sites>Edit>WPLANG.

        Each site has a unique language setting which works fine when the plugin is disabled. As soon as the plugin is enabled the frontend shows up in English (the plugins default master language).

        • Ok, just give me some time to set up a test system with multisites enabled so I can test it myself.

        • After setting up my first WordPress mutlisite testing environment, I think I have found the error. It should now work with single and multisite installations. Just update to version 1.5 and test it again.

        • Yes, that sometimes takes to long. On wordpress.org it was updated just 5 minutes ago. Let’s see how fast you’ll see it in your backend. Maybe loggin off and on again will make the update appear.

        • That’s great, I am glad I could helped. And many thanks to you for pointing out that error so other users will also benefit from the changes!

  10. Hi, Love your plugin. I found there is a small problem in the admin panel button function, at least for my blog. You use ‘http://’ at the beginning of $link. It came out like ” http://wp-admin/…”, of course page not found.
    I made a small change of the script, using home_url() to replace ‘http://’, and it comes perfect.

    Don’t know if anyone else has the problem. Just let you know this potential bug.
    Regards, Justin

    • Hi Justin,

      I finally fixed the issue with the link. It was a bit more complex than your solution as some users store their WordPress installations in a subdirectory. But I think I fixed it for every case that might happen.

      I also fixed a XSS vulnerability issue some guy from Mozilla told me. So I would recommend you to update to the latest version. You may want to backup your file so just in case it does not work for you. But I would appreciate it a lot if you can just tell me if the fix still works on your blog.

      Bernhard

        • YAY! Thanks for your response Justin and for your bug report! Now I can say that I am really proud of my new and secure version 😉

    • Thanks for your bug report. The source I got the icons from had a wrong file name for Estonia and so I copied the wrong icon. Now it should be all correct, after updating to version 2.0.3 of the plugin.

  11. Hi,

    First of all, thank you for the plugin! Just what I needed! Thank you!

    Second of all, I think the plugin has an AJAX issue. I’m using it for a WooCommerce-based site. And I’m using your plugin to retain the backend language in English while having the frontend in my local language. Anyway, the problem that I’m encountering is that translations are lost after AJAX call. I had posted a question regarding this in WordPress StackExchange. Maybe you should read the answer that I received and see if maybe you can make your plugin integrate with AJAX call.

    See answer here: http://wordpress.stackexchange.com/a/133358/1044

    I really hope you can make it work! Cheers and thanks again for the plugin!

    Regards,
    ALDI

    • Hi Aldi,

      thanks for your bug report. I never had that issue myself and haven’t though about it. Please check out my answer on WPSE and test the new version 2.1 with your website. If the issue is gone, please leave another comment. If it’s still on your website, we have to find other parts which might break the localization.

      Regards,
      Bernhard

  12. Hi, I have a problem with this plugin. When loging in through other ways, e.g. a maintenance-mode-plugin, the language doesn’t seem to be set. So in Events Manager I get:

    Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /var/www/clients/client16/web38/web/wp/wp-content/plugins/events-manager/events-manager.php on line 408

    Which is caused by get_locale() returning null.

    Is there an easy way to fix this?

    • Hi Joakim,

      thanks for your bug report. There were indeed some conditions that would return an empty locale for the backend.
      I just patched the plugin and uploaded it as version 2.1.2 to the WordPress plugin repository.

      Please instll the new version and test it again. It would also be nice if you can tell me, if it is working for you now.

      • Wow, that was fast. It works like a charm now. The language I chose for the backend is only coming up when logging in through /wp-admin/ though, but that’s not a big issue.

        • What do you mean with “only logging in through wp-admin”? How can you login in differently?

          The last chosen language is also stored in a cookie, so it should be the same, no matter how you log in to your backend.

          • Ah OK. I didn’t know that this plugin is not using the default login mechanism. I would guess that they wipe the session and all cookies and therefore you have to switch the language again. But I think this should be an edge case and not too much of an issue for users, to do that one extra click 🙂

  13. There seems to be a bug. Sometimes the backend language reverts to default (haven’t studied it thoroughly) and when changing it back… in fact eveytime you change the backend language (just tested), it sets the frontend language to the same as the backend, so you have to go to Settings / General to change back the frontend language. I’ve seen this behavior on multiple sites now.

    • I have never experienced such a behavior, even on multisite. I also can’t think of any possibility, where my plugin would change the frontend language. It only sets the used language for the backend an only when a page from the backend is requested. It never saves this language setting persistend to the database or ny configuration file.

      So I would asume, that any other plugin is causing this issue. Do you have any multilingual plugin installed or any plugin, that changes the backend? Maybe we can find the problematic plugin so I can see if I can fix mine or if you have to contact the other plugin developer.

  14. Hi,
    My name is Borisa Djuraskovic. I am associated with Web Hosting Hub community team.
    I found your Backend Localization plugin at https://wordpress.org/plugins/kau-boys-backend-localization/ very interesting. I would like to translate it to my native Serbo-Croatian language and help people from my community find your plugin useful too. But you would need to create the translatable .pot file first in order for me to proceed. Please let me know if you are willing to do that so I can translate it.

    Regards,
    Borisa Djuraskovic

    • Hi Borisa,

      you are right, the pot file is not really up to date. Up you can also just copy the German translation file and rename. But if you really need a pot file for your translation tool. I can update the one from the plugin.

      I would really appreciate your help translating the plugin. Just send me over your complete po file and I update the plugin mention you in the readme.

      Regards,
      Bernhard

    • Hi Andreas,

      that’s most probably, because the theme/plugin with missing translations does not provide a Finnish translation file. My plugin does only switcht the language in the backend but it not translating any texts. So if there is not translation file, the default language (mostly english) will still be shown.

  15. Just fyi, there’s a tiny typo bug in backend_localization.php on line 347 that fills up the error log:

    HTTP_REFERER -> HTTP_REFERRER

  16. Is this plugin working properly still? We have a bunch of site sites in different languages but our developers are english speakers so that might be very useful for us. Please confirm before we install because I see that this post is quite old. Thanks 🙂

    • Hi Uudet,

      this plugin is still working. I also use it on my site.

      But with WordPress 4.7, there will be a similar functionality in the core, so you might not even need the plugin anymore.

Leave a Reply

Required fields are marked *.