1

I have a Drupal 7 site in Spanish, and I found several strings that are not translated. So, I took note of them and went to the Translate Interface admin section and translated everything except for a string.

The comment form has 3 labels: "Your name", "Subject" and "Comment". The first two are perfectly translatable, but "Comment" does not appear in the translation list.

I've implemented hook_form_alter() in my theme's template.php, to see the form structure with:

if( $form_id == "comment_node_blog_entry_form" ) {
  dpm($form);
}

According to dpm(), the 'Comment' string (not translatable) is referenced as:

$form['comment_body']['und']['#title']

while the 'Subject' (translatable) string is referenced as:

$form['subject']['#title'];

If I try:

if( $form_id == "comment_node_blog_entry_form" ) {

  // this works:
  $form['subject']['#title'] = 'TEST';

  // this doesn't work:
  $form['comment_body']['und']['#title'] = 'TEST2';
}

So the questions are:

1.- Why "Comment" is not translatable? Shouldn't it have the same exact behaviour as "Subject"?

2.- Why can't I change the "Comment" string in my hook?

3.- If it's finally possible, will be possible to assign it to = t('Comment'); so that the translation is available in the "Translate interface" section?

Thanks.

PS: Other strings that I can't translate are the text formats ("Full HTML", "Filtered HTML", "Plain text", etc). I will try to translate also by using a hook, when I solve this.

Your Answer

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

Browse other questions tagged or ask your own question.