Posted on: 11/27/06 08:21am
By: Dazzy
Hey all
I installed the latest beta this morning and started fooling with the multi lanaguage aspect and I think I've pretty much got it figured.
One question though is it currently possible to indicate different blocks for different lanaguages?
Let me explain, I currently help run a motorcycle club website, we use blocks for containing various links around the site, staticpages etc.
I'd like to translate these for the different lanagauges and only show the relevant block depending on the users lang setting.
Many thanks
Re: Multilingual Testing
Posted on: 11/28/06 11:35am
By: Dazzy
Might have come up with a solution although it will be an administrative nightmare.
Create Logged-in_lang groups for each specified lanaguage and only allow members belonging to that group to access the appropriate blocks.
Admin nightmare in the fact that I would have to manually set the users to the appropraite groups.
Re: Multilingual Testing
Posted on: 11/28/06 03:50pm
By: Dirk
Yeah, blocks are not multi-lingual - that would cause some issues with the built-in blocks and those provided by plugins.
Out of curiosity: Do you have a lot of blocks that need to be multi-lingual?
We do have an API for blocks (see CUSTOM_showBlocks in lib-custom.php) - maybe that would help you?
bye, Dirk
Re: Multilingual Testing
Posted on: 11/28/06 05:05pm
By: jmucchiello
Couldn't the blocks code take the $bid and look for a block called $bid_$lang and if it finds it, use that block instead of the base $bid block? The only trick after that is filtering out the _$lang blocks when building the admin_list of blocks.
The builtin blocks should already be sufficiently multilingual based on the builtin language files.
Something like this should work in COM_formatBlock (code is 1.4.1 specific):
Text Formatted Code
$lang = COM_getLanguage();
if (!empty($lang))
{
$sql = "SELECT * FROM {$_TABLES['blocks']} WHERE bid = '{$A['bid']}_$lang'";
$result = DB_query($sql);
$row = DB_fetchArray($result);
if (is_array($row))
{
$row['is_enabled'] = $A['is_enabled'];
$row['blockorder'] = $A['blockorder']
$A = $row;
}
}
Then when you make the language specific blocks, set them as disabled so they don't show up in the normal lists.
Re: Multilingual Testing
Posted on: 11/28/06 06:24pm
By: Dazzy
Not overaly many Dirk, just something I'm fooling around with, if my site goes multi lingual I would like it all multi lingual, minus the forum. First step is to try an update the relevant langauge files though.
Re: Multilingual Testing
Posted on: 11/28/06 07:59pm
By: Dazzy
I think i understand what your saying jmucchiello mind you all that stuff is still way beyond me.
Re: Multilingual Testing
Posted on: 11/28/06 09:20pm
By: jmucchiello
Okay, with a site to work with at home, this becomes a simple hack. I've cleaned up the code. It really is very simple. You create a block and give it a name, for example: welcome. This is the block you use to position the block on the page. Then if you wish to specialize the block, you append an underscore and the language id: welcome_de. This block is "disabled" so that users don't see both welcome blocks. When a german reading user hits the page, the welcome_de block is shown in place of the welcome block. Here is the tested code. Replace the top of the function COM_formatBlock found in lib-common.php with this text:
Text Formatted Code
function COM_formatBlock( $A, $noboxes = false )
{
global $_CONF, $_TABLES, $_USER, $LANG21;
// HACK:ML_BLOCKS:Start
$lang = COM_getLanguageId();
if (!empty($lang))
{
$sql = "SELECT * FROM {$_TABLES['blocks']} WHERE name = '{$A['name']}_$lang'";
$result = DB_query($sql);
$row = DB_fetchArray($result);
if (is_array($row))
{
$A = $row;
}
}
// HACK:ML_BLOCKS:End
$retval = '';
There are a lot ways you mess yourself up with this. The default block could be a text block while an alternate language block is a php block. I have tested the case where the welcome blocks were RSS feeds with different content and that seems to work.
The hack seems stable. Try it out. Hopefully this can find its way into CVS....
Re: Multilingual Testing
Posted on: 11/29/06 04:34am
By: Dazzy
Your a genius, I'll give this some testing today, I agree this would be a useful addition to the cvs.
Many thanks
Re: Multilingual Testing
Posted on: 11/30/06 05:07pm
By: jmucchiello
So how'd it go? I'm curious it works as you hoped.
Re: Multilingual Testing
Posted on: 11/30/06 07:04pm
By: Dazzy
been working well through tests, php blocks work too
Exactly what I wanted, many thanks again
Would still love to see this added to the cvs, Dirk, Blaine?
Regards
Re: Multilingual Testing
Posted on: 01/12/07 03:14am
By: samstone
I trided this code, but doesn't seem to work.
--- edited ---
It works! I had to initially disable the alternative block.
Thanks!
Sam
Re: Multilingual Testing
Posted on: 01/02/08 11:22am
By: LWC
Quote by: DazzyI would like it all multi lingual, minus the forum.
Not possible with the current forum version, because if your forum is LTR, users with RTL languages wouldn't be able to work with it, and vice versa. The forum (or individual categories/topics) must have a direction setting in order for your plan to work.
Re: Multilingual Testing
Posted on: 05/09/08 07:46pm
By: samstone
The hack seems stable. Try it out. Hopefully this can find its way into CVS....
I don't see this in the GL 1.5 beta. What does it take to get this in, even though it's not a big deal since it is a simple hack. Since GL is already multilingual, adding this would only make the feature more complete.
The main reason I came to the thread is because I found out that the language specific block does not honor side specific layout, meaning when it is set to display on the left, it does not take blockheader-left.thtml, instead it takes the generic blockheader.thtml.
Anyway to enforce that?
Thanks,
Sam
Re: Multilingual Testing
Posted on: 05/09/08 08:17pm
By: samstone
Found it. The layout is picked by the /layout/theme/functions.php. The left or right dressing is applied only when the block is enabled. Since the multilingual blocks are not supposed to be enabled, the following code needs to be removed.
WHERE is_enabled = 1
Hope this helps!
Sam
Re: Multilingual Testing
Posted on: 05/09/08 08:29pm
By: jmucchiello
I don't run a multilingual site so I can't really test this. But I was wondering if this hack still worked. It's too bad it never found its way into 1.5. Losing the old bug tracker probably caused its loss. Maybe someone running the hack can revive the old bug/feature request.
Re: Multilingual Testing
Posted on: 05/10/08 12:03am
By: samstone
Hi Joe,
I haven't tested it with 1.5b yet, but looking at the lib-common.php, the hacking area still look the same, so I am pretty sure the hack still works.
Since this is just a few line of hacks, I hope the development team is willing to add it in to the next beta release.
Thanks,
Sam
Re: Multilingual Testing
Posted on: 05/10/08 09:57am
By: jmucchiello
Since it is a new "feature" I suspect they won't but you can put into bug tracking and hope.