Welcome to Geeklog, Anonymous Wednesday, November 27 2024 @ 03:43 pm EST
Geeklog Forums
Multilingual Testing
Status: offline
Dazzy
Forum User
Full Member
Registered: 07/19/03
Posts: 200
Location:N. Ireland
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
Dazzy
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
Dazzy
18
12
Quote
Status: offline
Dazzy
Forum User
Full Member
Registered: 07/19/03
Posts: 200
Location:N. Ireland
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.
Dazzy
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.
Dazzy
15
23
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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
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
22
15
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
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):
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.
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.
15
15
Quote
Status: offline
Dazzy
Forum User
Full Member
Registered: 07/19/03
Posts: 200
Location:N. Ireland
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.
Dazzy
Dazzy
20
16
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
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:
{
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....
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 = '';
The hack seems stable. Try it out. Hopefully this can find its way into CVS....
19
21
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
So how'd it go? I'm curious it works as you hoped.
12
14
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Quote by: Dazzy
I 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.
18
15
Quote
Status: offline
samstone
Forum User
Full Member
Registered: 09/29/02
Posts: 820
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
14
20
Quote
Status: offline
samstone
Forum User
Full Member
Registered: 09/29/02
Posts: 820
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
WHERE is_enabled = 1
Hope this helps!
Sam
16
23
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
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.
17
19
Quote
Status: offline
samstone
Forum User
Full Member
Registered: 09/29/02
Posts: 820
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
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
18
17
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
Since it is a new "feature" I suspect they won't but you can put into bug tracking and hope.
12
14
Quote
All times are EST. The time is now 03:43 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content