Skip to main content
knackforge blog knowledge base

Make panel's title translatable

Panels provides great salvage to those lost in the sea of page partition and block placement. It might take more than one blog to completely explain all the concepts, merits and advantages of using panels module in our site. But those who use Internationalization might differ a bit with my statement ! Yes, One of the shortcomings that I noticed recently in the panel's module is its ability to deal jointly with the Internationalization.

The panel module divides the page as per our requirement, creates menu items based on the page, has inbuilt contexts too and many features can accompany this list. But one basic feature that all developers would complain about the panels module is "Why is the title of the panel not appearing in translation interface?".

I did have a chance to think about this question in my recent project, instead of just pointing the finger out at the rich enhanced Panel module I thought of finding a solution. In the middle of my hunt I came across hook_panels_pane_content_alter. The below code shows the solution to this problem

  1. // Panel alter to make the title translatable.
  2. function hook_panels_pane_content_alter($content, $pane, $args, $context) {
  3.   if (isset($content->title)) {
  4.     $content->title = t("!title", array('!title' => $content->title));
  5.   }
  6.   return $content;
  7. }

Note : This issue too deals with the panel's title translation, but no real test has been made to ensure that the provided patches are working fine. Hope this feature is moved to panel core and the fix is made at the earliest.