Drupal 7 – Translate the title field label of content types

If you enable the Multilingual content of i18n module, a Translate tab will
 

Click the translate link and you can translate the node title field label.

 

Alternatively, if you want to translate the title field label on the node form without enabling the Multilingual content, you can do it on code level.

With the help of the Field translation in i18n module, we can find the the field label in Translate interface. But the title field label cannot be translated in the same way.

So i alter the node form and wrap the title string with t(). This can be done by creating a custom module and implement the hook_form_alter() as follow.

function <module>_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#attributes']['class'][0] == 'node-form') {
    $form['title']['#title'] = t($form['title']['#title']);
  }
}

 

Done =)

Advertisements

2 thoughts on “Drupal 7 – Translate the title field label of content types”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s