"Recent posts" Block title doesn't get translated by localization module

Ralf Saalmueller - August 10, 2007 - 13:56
Project:Drupal
Version:5.7
Component:language system
Category:support request
Priority:minor
Assigned:Unassigned
Status:closed
Description

We have a dual language (content and front-end) site and found out that way, that the menu item in the nevigation menu called "Recent posts" doesn't get translated even if there is a translated string in the localisation database.

#1

Gábor Hojtsy - August 11, 2007 - 16:04

Did you modify the menu item? In case you modify any property on the menu item, it is considered a user defined menu items, and is not translated anymore.

#2

Gábor Hojtsy - October 1, 2007 - 10:03
Status:active» active (needs more info)

Any information before we close the issue with no feedback?

#3

kdebaas - May 24, 2008 - 14:35
Version:5.2» 5.7
Status:active (needs more info)» active

I have the same issue: When enabling the tracker as a block, adding the standard title "Recent posts", the title does not get translated when switching languages. On top of that, the title of the tracker page itself also does not get translated. (it did, before enabling the block)
The comments_recent block switches titles normally.

#4

Gábor Hojtsy - May 24, 2008 - 14:48

Did you specify a custom title (with text "Recent posts") or did not customize that block at all?

#5

kdebaas - May 24, 2008 - 15:13

I did indeed. I noticed that the same happens with the standard recent comments block, but the other way around: if I enable a page view of it as well, its title is not translated.
If this is a feature, and not a bug, what would be the most consistent way around it?
Thanks

#6

Gábor Hojtsy - May 24, 2008 - 15:23

Do not specify a custom text. As soon as you specify something custom, Drupal sticks to it and will not translate. Same happens to menu items. If you rename them to some title of your choosing, the translation will not run anymore.

#7

kdebaas - May 24, 2008 - 15:33

I understand, and anticipated this answer. However, if I need a title for the "Recent posts" that is translated into other languages, is there some way of achieving this without creating a new block per language?
Thanks

#8

Gábor Hojtsy - May 24, 2008 - 15:37

Drupal itself only does built-in interface translation and does not translate user input (such as custom block titles or menu items). For this, you need the i18n or localizer modules (which solve the block issue with different solutions to my understanding).

#9

kdebaas - May 24, 2008 - 16:24
Title:"Recent posts" don't get translated» "Recent posts" Block title doesn't get translated by localization module
Category:bug report» support request
Status:active» fixed

Thanks. To solve my problem I followed the answer to this issue:

There seems to be a variety of behaviours when it comes to i18n/localization and blocks [snip]. 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.

Solution:

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

To be precise I changed

<?php
print $block->subject
?>
to
<?php
print t($block->subject)
?>

#10

Anonymous (not verified) - June 7, 2008 - 16:35
Status:fixed» closed

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

#11

evolvingweb - June 23, 2008 - 15:41

kdebass, thanks a lot for pointing out this useful trick.

 
 

Drupal is a registered trademark of Dries Buytaert.