Browsing the internet, I noticed the necessity to have a blog in two or more languages. It’s a necessity I’m having too, so the first thing I did was a search into the official WordPress plugin repository, convinced that the solution to my problem was a few clicks away.
I was much, much wrong.
Anyway I observed all tricks and plugins developed in order to solve this WordPress deficiency.
Let’s see them and discover their weak points.
During the following examples I will consider the idea to create a blog in two languages, even if the same concept can be widened to a number of n languages.
Creation of two different blogs, with a homepage showing a language selection
It’s the simplest solution, anyway lacks the capability to switch form one language to another from the inside of the blog.
Creation of a button with a link to Babelfish or another service of online translations
Online translation services aren’t yet that smart to expect of being able to translate posts much more complex than “Hello world” without losing the sense of the post.
“Polyglot” plugin and other plugins inspired by it
It’s the best solution at the moment, even if lacks some options like comment separation based on their language.
No one of those systems however resolved my requirement, consisting in two distinct blogs (even hosted on two different domains), where not necessarily every page of the blog A had a correspondence in blog B, but if it should eventually exists, was reachable by a hypertext link.
Having installed WP two days ago, I do not have the required knowledge (neither the time) in order to develpo a plugin, anyway I promise to make it in a quiet moment of my work (translation: never ever), and I hope however that my small intuition shall open the way to the creation of a well coded plugin.
What do we need for having a blog in two languages?
2 images of small flags
2 installations of WordPress completely independent (two different domains, or two different databases)
1 new table in database
A bit of php coding
About the flag icos, I think you can easily draw or find them in the web.
Personally, I love these ones.
As far as the installation of WordPress, being a neophyte I cannot help you very much… just install it and eventually customize it to display the sidebar on every page, because in my example we’ll see how to change sidebar content to insert the language change link.
Let’s start with the new table
CREATE TABLE `wp_language_jump` ( `id` int(11) NOT NULL auto_increment, `page` text NOT NULL, `link_to` text NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1
where the interesting columns are “page” that will contain the address of the page in which inserting the link, and “link_to” that will contain the link (or links) to which page we want to publish the translation.
In a practical example I installed one version of WP in root of http://www.emanueleferonato.com/ and another in “ita” directory href=”http://www.emanueleferonato.com/ita”>www.emanueleferonato.com/ita. I want that from each of two blogs page there is a link to its proper translation, and in the same way I will deal with all future pages.
The row I inserted in the table is:
INSERT INTO `wp_language_jump` VALUES (1, '/index.php/', '/ita/');
Which communicates that from the homepage (index.php) I want to link to the italian blog homepage.
My links should be different than yours because I used “date and name based” permalink structure, please refer to documentation supplied with WP in order to understand what type of links (or permalinks) you used, even if as far as I can see more than 90% of blogs have a links structure like mine.
In the same way I want the italian homepage to link to english one, so the row is:
INSERT INTO wp_language_jump VALUES (2, '/ita/index.php/ita/', '/');
Subsequently you can insert all page link translations you want.
Now let’s see the php script. I want my link to be at the top of sidebar, so I am going to edit sidebar.php from WP administration panel, menu Presentation -> Theme Editor -> WordPress Default theme files.
You are obviously free to choose where to insert the script.
I did it after