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.

Comments

gábor hojtsy’s picture

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.

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

Any information before we close the issue with no feedback?

kdebaas’s picture

Version: 5.2 » 5.7
Status: Postponed (maintainer 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.

gábor hojtsy’s picture

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

kdebaas’s picture

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

gábor hojtsy’s picture

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.

kdebaas’s picture

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

gábor hojtsy’s picture

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).

kdebaas’s picture

Title: "Recent posts" don't get translated » "Recent posts" Block title doesn't get translated by localization module
Category: bug » support
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 print $block->subject to print t($block->subject)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

dergachev’s picture

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