By Sebastiaan de Jonge, published on Tuesday, September 7, 2010 at 16:00

We all know TYPO3 supports multiple languages in as well the frontend as the backend. But this flexibility is for some major corporate websites not enough. Recently I had to deal with one that had 43 different localizations.
There were several other small points of interest as well though. 43 Localizations is not the same as 43 different languages. In fact, there were only 6 different languages. They were just spread over 43 regions. Of which the content could actually be the same, or different.
Instead of setting up 43 page trees, I decided to take a different approach. I decided just to take use of TYPO3s' built-in support for languages. Now with 2 maybe 3 languages, this would give no problem at all of course. But imagine seeing each record 43 times on a single page?So I decided to built a 'little' tool, to help us solve this problem. I called it the 'Localization Filter'. The idea is, to specify at any time, which content from which languages should be displayed. So editors could easily switch between languages without much fuss.In my case this was especially useful, because like I said before, there are only 6 real languages involved. Otherwise a construction with different backend users having only access to specific languages would have been an option as well.
The result of what I had in mind and actually created was actually quite cool (if I say so myself). Switching between languages can be done as shown below.
Since the icon is displayed at the top bar, it can be accessed from anywhere inside the TYPO3 backend.
Once a selection is made, it's stored in the backend users' session. The list view and page tree are automatically refreshed. So no further action is required to display the proper content.
Too make things clearer to the user/editor, I've built in some nice flash messages as well. To show the user when and what languages are filtered out.
Next to that there is an option to apply the filter on the page tree as well. This has a built-in check that will make pages gray if and when a page is not translated in any of the selected languages (checks the page language overlay).
Of course I've built this tool the way I thought it should be. The following features are not yet supported.
  • Web > Page
  • Templavoila
If you think I had to hack my way into the TYPO3 core to achieve this you are wrong. By using some of the hooks found inside the TYPO3 core and some clever tricks I was able to quite easily build this. The most time consuming was however figuring out how some of the core and backend parts of TYPO3 work. By reverse engineering certain processes I found several hooks I could use to make my filter behave like it should.
In total I used just 4 hooks, to achieve this. These are the ones I used, and what I used them for.
$GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems']
Add an additional toolbar item, this is the flag in the right top that triggers the filter dialog.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook']
I used this hook to add an additional JavaScript/ExtJS file that is used to render the filter dialog. I also included a small extra CSS file with this.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray']
This hook I used for altering the query that displays the records in Web > List. This is where the actual filtering is done.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.webpagetree.php']['pageTitleOverlay']
For altering the page tree, I have used the following hook.
Now if you ever use any of these hooks to achieve something like I did, you will find out you will not always get what you are looking for. Most of these hooks are either called more than once, or on pages where you don't want your action to take place. To bypass this, you will need to filter out these requests.Another problem I encountered was including the JavaScript library at the right position. I always ended up with the script being loaded, later then it should be. In order to solve this problem I needed to access the t3lib_PageRenderer. The only problem was that this object was protected. I had no access to it.I could bypass this by making a new instance of it inside my function. Since t3lib_PageRenderer is a singleton class, it could only be loaded once. So by calling the following:
$o_pageRenderer = t3lib_div::makeInstance('t3lib_PageRenderer');
I was still able to access the otherwise 'inaccessible' object.
It took me quite a while to find out what I needed for my extension. This also means it took quite some time to build it. But in the end, I made myself better out of it by understanding better how the TYPO3 backend works.Another thing this proves is that it shows just how flexible TYPO3 actually is. I was able to make all these changes, without changing anything in the TYPO3 core.
The extension is currently private, I have not chosen to share or publish it (yet). However if people are interested in it, or would like to further develop it, I will be happy to share it in the TYPO3 forge. So if people are interested, please let me know.
Since I've had some requests I have chosen to publish the extension only here. Feel free to grab it and try it out. The extension has been developed on/for TYPO3 4.4. I've done a quick test on 4.5 LTS, unfortunately there are already some things broken there. So if you want to run it above 4.4 I guess you will need to apply some changes. Unfortunately I can't come up with the time to modify the extension and make it work for newer TYPO3 versions. Perhaps this will happen in the future.If there is any interest in a Forge project on which we might be able to collaborate, please let me know.
Benjamin Serfhos
Benjamin Serfhos - Wednesday, September 8, 2010 at 06:14

This can make it so more userfriendly for websites with multi language..I see the potential! The TYPO3 backend can improve in ways like this.

Keep up the good work!

Remco
Remco - Wednesday, September 8, 2010 at 07:50

Cool you got it working.

Ingo
Ingo - Tuesday, September 28, 2010 at 10:46

I'd probably move the setting to the user settings though, I guess they won't change every day...

Sebastiaan de Jonge
Sebastiaan de Jonge - Monday, October 4, 2010 at 10:16

That would prevent users from changing it themselves. It would also make the interface less easy to use, since you would have to go to the user settings every time you would like to display something else..

Egbert
Egbert - Wednesday, January 18, 2012 at 14:36

Can you share it on forge or send me a copy? I tried fb_hybridmultilanguagetree but thats not working anymore.

Sebastiaan de Jonge
Sebastiaan de Jonge - Thursday, July 12, 2012 at 11:08

Alright, there have been enough requests. I will try to publish a version of this extension within the next week. The extension has however not been tested/used after TYPO3 4.3.x, so perhaps it will need some tweaking to work again.

Cheers,Sebastiaan

Nina
Nina - Thursday, June 14, 2012 at 13:02

Would you share the extension on forge or send me a copy too? It sounds like a great tool!

Rainer
Rainer - Friday, March 15, 2013 at 13:44

Hi,

thanks for this great implementation. Do you know what has to be done to get it work in TYPO3 4.5 or higher versions?

GreezRainer