How to translate a panel page title and a pane title

by Pavlos   Last Updated October 04, 2017 18:07 PM

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.

Tags : 6 panels i18n-l10n


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

Letharion
Letharion
January 29, 2012 00:12 AM

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.

vegardjo
vegardjo
November 29, 2012 13:16 PM

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

Pere
Pere
April 03, 2014 13:17 PM

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Ă 

asiby
asiby
August 23, 2014 03:52 AM

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.

BE-WEB
BE-WEB
November 12, 2015 11:21 AM

Related Questions


Using panels and panelizer with i18n

Updated August 22, 2016 08:04 AM


Panes' Title translation

Updated March 10, 2018 12:07 PM

Panels block title translation

Updated May 11, 2017 17:07 PM

Translate Term in Panels

Updated August 12, 2017 08:07 AM