5

I want to ask if there is a way to translate the title of a panel and also its panes titles whatever content they are. I use panels to override user/%user page and there i putted as panel title the token "Profile of %user:user-raw" and i have also other content(views,blocks,nodes) with their titles. Thanks in advance.

8

Latest version of Panels module (7.x-3.4 as today) includes Panels translation module (i18n_panels), which provides a fix for this issue.

  • 2
    +1, I'll leave my answer around, but this is now the correct answer. :) – Letharion Apr 4 '14 at 14:06
5

I'm sorry to say that, in short, you cant.

Translation never was a feature of Panels until very recently, and the patch is currently only for D7, although it will likely be backported.

The problem at it's core is that Pane titles could come from a source that has already translated, which makes translating them a bit complicated.

With that said, there is a work-around:

/**
 * Implements hook_panels_pane_content_alter().
 */
function HOOK_panels_pane_content_alter($content, $pane, $args, $context) {
  if ($content->title) {
    $content->title = t($content->title);
  }
  return $content;
}

But it's important to realize that if you have a title like

Content tagged with %term

then you will end up with one translatable string for each value of %term.

1

Just had the same issue, where the panel title I needed to translate was "on same day as %node:title". I fixed this with the Custom token module, where I added a custom node token with this content:

<?php $on-same-day = t('On same day as'); return $on-same-day; ?> 

then translated this token via admin -> configuration -> translate interface, and referenced it into the panel as such:%node:on-same-day %node:title - worked like a charm!

..this for Drupal 7, but should be the same for 6.

  • One issue with this is that is requires the PHP module, which is a really bad idea to use. – Letharion Nov 8 '13 at 21:45
1

Yes it is possible to translate the title of a panel page. It just depend on how you want to approach it.

In my case, the Panels Page Manager lets you choose among three options for the page title. The option is called Title type:

  • No title
  • Manually set
  • From Pane

When you set the title manually, it is hard coded in a way that seems impossible to translate. I gave up on it after spending a considerable amount of time searching for a solution.

When you choose the option "From Pane", this lets you specify which panel pane's title should be use for the page title. Here is how you do it:

  1. Set the Title type to "From Pane". This will hide the text field for the title.
  2. Click on Update or Update and Save. After that, you will notice that the contextual menu for each pane will have a extra option called Panel title. That option is just a toggle menu item. So when you click on it, it will have a check mark next to it. Only one pane can have that check mark at any given time. Panels will take care of make sure of that.
  3. Add a pane that is translatable somehow. In my case, the Bean module was install. I used it to create translated chunks of contents that I could use as panes. Block are a little awkward when it comes to translation. In your case, use whatever you have that can be used as a Panels Pane and that is translatable.

It may seems like to many steps and chunks of content to handle just for specifying a page title, but that's what Panels is about. Peacing a page together using panes from here hand there.

Have fun.

Et Voilà

0

In case of not using i18n module but Entity Translation module, you can't use i18n Panels module.

The Panels module comes with a few templates. One of them, panels-pane.tpl.php holds the title, like this:

  • Copy that template file to your themes directory.
  • Place the $title variable in the t() function like this: <?php print t($title); ?>
  • Empty cache, refresh your page and the title comes available for translation at /admin/config/regional/translate/translate

Not ideal, because you don't want content in there, but a good workaround.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.