Making EE truly multi-lingual

January 17, 2011

This past weekend I tweeted about the awesome multi-lingual add-on I just got working. I think it's so awesome that I just can't wait to share some details...

ExpressionEngine is amazingly flexible. We all know it, and thats why I'm totally hooked on it. Even with it's flexibility there hasn't been, what I consider, a true multi-lingual add-on created for it. Modules such as Multi Language Support, Multi Language Module, and Simple Translator tackle the issue and do a very good job of it, but they only go so far. The modules usually only support key/value replacements, and Simple Translator (and similar techniques) require multiple custom fields, which can clutter up the publish screen, and add to overall maintenance. Simple Translator and it's sibling methods are also the only ones that tackle translating normal entry data... which is where most of your site content is. To top it off, if you have a very large site, you may quickly run into the MySQL column limit issue (roughly up to 4028 columns in an EE table) and scalability is out the window.

The Solution

At The Nerdery we have a very large scale EE site coming up. It has 12 languages, and possibly more in the future. I'm expecting 100 or more custom fields. Existing multi-lingual techniques simply won't do. I had to come up with something different. At first I thought about just making all the custom fields a Matrix field with 12 rows (1 for each language), but what happens when I actually need a Matrix field? You can't put a Matrix within a Matrix. Not to mention we're back at the same problem as before where the Publish screen would be very cluttered. 

Then I looked at creating a new fieldtype that was basically a simple Matrix with just 2 columns. One for the fieldtype it would contain, and the other would be the fieldtype's settings. Every custom field would actually be this new fieldtype, then you would sub select which fieldtype it would contain, such as WYMeditor, Playa, Matrix etc. With this approach I could be able to save the field's data into an external table, just like Matrix does. The first attempt at this worked to a degree, but managing the field settings and the Matrix within a Matrix concept was quickly making it a brittle chunk of code.

While the first attempt was a failure, it lead me down another path. What other ways could I get all the data into a custom table and bypass the exp_channel_data table all together? At this time I was working with EE 2.1.2, and was able to extend a core class much like I did in Custom System Messages. It hardly had any functionality, but I could tell it was going to work. Then I upgraded to 2.1.3, and nothing worked. EllisLab changed how some of the core classes load, so I was back to square 1. Three hours later, I found the problem and a work around, which includes a tiny core hack. I can't give away trade secrets just yet, but rest assured it works as you can see in the video below. In order to get Matrix to work, it also requires a small addition to it's code. I know these changes are not ideal, and in a perfect world we wouldn't have to touch core code, but at this point I don't see a way around it.

What you see in the video is still very beta. It has not been tested on a full site yet, and has quite a bit of functionality to go, but the core of it is working and finished. Things I still need to sort out are how the Title field will work with other 3rd party modules such as Structure. Searching will also be an issue. The project this is being developed for is not using EE's built in search, so for us it isn't as big of an issue, but I'll try to sort it out. You might notice at the end of the video the template used to render the content is completely normal. No additional template tags are required to make this work. I also don't want to detract from other great multi-lingual add-ons that I mentioned earlier, and the upcoming Transcribe module, those add-ons have their place, and ideally would be used in conjunction with this one, which is just taking a different angle to solving a problem.

The video:

Release Date?

I have no idea. It is still in development, but rest assured it will be released in some capacity because I think it's too important to the community not to.


comments powered by Disqus