I am working on a website in three languages. My problem concerns the titles of blocks. There seems to be a variety of behaviours when it comes to i18n/localization and blocks, but the one I need most is missing.

First, some blocks (I'll call them 'system blocks') seem to have automatic translation of block title. For instance, Who is online. It seems to work even without the Internationalization module. Or block titles can be translated through the localization engine.

Then there are custom blocks. The titles of these blocks cannot be translated through the core localization engine, and the i18n-blocks module seems to suggest that the only solution is: create one block per language and put them together using a multilingual block.

What I desperately need to avoid is creating one block per language in cases, where the content of the block is language-independent and only the block title needs to be translated, for instance in the case of the Random Image block module.

How can I get the titles of custom blocks translated without the need to have trillions of identical custom blocks? I have searched, tried the Localizer module, whatever.

Thanks for any suggestions. Roman

Comments

intu.cz’s picture

Title: Localization of block titles » Localization of block titles - solved

This problem can be solved by using the block.tpl.php, where one can put the block title variable inside a t(). Works great.

Roman

jose reyero’s picture

Status: Active » Closed (fixed)
new_user22’s picture

Version: 5.x-2.2 » 5.x-3.x-dev
Component: Module i18nblocks » Code
Assigned: Unassigned » new_user22
Status: Closed (fixed) » Active

It does not working!
The block.tpl.php file is:

print $block->module .'-'. $block->delta; " class="clear-block block block- print $block->module ">

if ($block->subject):

print $block->subject

endif;

print $block->content

When I use t($block) it is get the error!

giorgosk’s picture

try using

print t($block->subject); 

because $block is not a string

elianm’s picture

It works great! Thanks a lot.

jose reyero’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.