Monday, May 14, 2012

Tagged under: , , , , ,

How to translate pane titles (Panels module) in Drupal 7


















Use Panels' hook to embed t() function (for example, your module name is my_module):

/*
 * Implementation of hook_panels_pane_content_alter
 */
function my_module_feature_panels_pre_render(&$display) {
     //panel title
     $display->title = t($display->title);
     //pane titles
     foreach($display->content as $pane) {
           if (isset($pane->configuration['override_title_text'])) {
                $pane->configuration['override_title_text'] = t($pane->configuration['override_title_text']);
           };
     }
}

3 comments:

  1. I tried to put this function in my theme's template.php but it doesn't work. Do I have to change anything in your code (maybe the 'dpm_feature' string?)

    ReplyDelete
    Replies
    1. I'm so sorry for late response! Yes, you must change dpm to the name of your module or theme. It was my fault, sorry, I copied my code and pasted here as a notice. The post is edited. I'll be careful from now on. Thank you! :)

      Delete
  2. Hi! If you're interested to efficiently localize Drupal websites, consider this online string management platform: https://poeditor.com
    You can use it with this plugin to automate the translation process more: https://poeditor.com/help/user_contributions#Drupal-Plugin
    Good day!

    ReplyDelete