On a fresh multi-language drupal-7.12 site with Captcha-beta2, the label for comment body persists on not being translated.

In the sample image attached, showing a basic page at /node/1?lang=de, I can for example fix "What code is in the image?" by adding its translation, but "Comment" (label of comment body) seems to be already properly translated, but the translated text does not show up.

I noticed an untranslated label 'Comment' in comment.module file, possibly corresponding to this comment body label. But even after the attached patch, body label still persists.. :(

CommentFileSizeAuthor
comment.patch363 bytesjfcg
bugsample.jpg24.76 KBjfcg

Comments

webbykat’s picture

I was able to reproduce this on a clean install of Drupal 7 by:

  • Downloading and enabling Locale, i18n, i10n_update
  • Importing the German .po file
  • Enabling the Multilingual option on the content type
  • Enabling Comments on the content type
  • Creating a piece of content and setting it to German language

I got the same results as the one in the screenshot above. In the translate interface, I noticed that Comment in the context of field:comment_body:comment_node_page:label hadn't been translated, but even after I added a translation manually, it didn't update.

Not sure if this is a bug against Internationalization or Drupal core. Leaving it here, but someone with more knowledge may want to move it. May be related to #1157426: Field system uses t() incorrectly and inconsistently.

webkenny’s picture

Version: 7.12 » 7.x-dev
Component: comment.module » field system

I am fairly sure this is an i18n problem. My understanding of #1157426: Field system uses t() incorrectly and inconsistently is that all t() directives were remove in Drupal 7.1 for fields. A follow up exists over on Gabor's excellent post on the topic: http://groups.drupal.org/node/149984

I don't know i18n enough to move this but following the thread it does appear the lack of the t() wrapper is intentional.

webkenny’s picture

Component: field system » comment.module
Status: Active » Closed (works as designed)

Got a little trigger happy there with my settings. Moving this back to comment.

webbykat’s picture

Project: Drupal core » Internationalization
Version: 7.x-dev » 7.x-1.4
Component: comment.module » Fields
Status: Closed (works as designed) » Active

I agree that the lack of functionality with t() is intentional, but there has to be a way to translate the Comment heading. There are lots of multilingual sites that use comments, so even if t() isn't the right solution, it's essential for them to have an intuitive way to get that heading in the new language.

From that post you cited, there's a relevant comment from Gábor Hojtsy:

There is an i18n_field module for this specific case, which was in limbo due to how core translated some things in error. Now that it is not going to translate them, we can fix the module and make it translate objects properly. Unfortunately not all occasions of the use of field labels, descriptions, etc. will be translatable because the code does not mark them in any way (why would it?). So once again, the i18n module will fill in this gap.

This seems like that kind of bug, so I'm moving this to Internationalization in hopes that it'll be a useful bug report.

jose reyero’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Does this happen only with Captcha module?

(If so, I guess this should be moved to that module)

webbykat’s picture

Sadly, I don't think so -- I didn't have Captcha installed on the site where I tested it out. It was a fresh install with only the modules necessary to get translations working.

jose reyero’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

AFAIK, it can be translated with i18n, just tested it and it works.

(Of course you need to enable i18n_field, and translate the string manually on the field settings tab)

webbykat’s picture

That was it - I'd done everything except enabling Field Translation! Thanks for that detail. Hopefully this was the original poster's issue as well. :)

miguel’s picture

I dont' know the internals of drupal but for a normal user it is not an intuitive way to download i118 and Variable to translate this only field (all other fields as Name, Homepage are correctly translated).
Is this really by design?

codemuncher’s picture

Using Drupal 7.15

It's not fixed by turning on field translation:

I tried to use the field translation in the comment field section for a content type.
I get errors like : '...non-object in i18n_field_page_translate()...', and following the thread on this it says I should use i18n DEV version. I shy away from using a DEV version since the Site already deployed in Production.

I had hoped i could fix the label using hook_form_alter(...),
but that didnt work either. It has not effect on either
$form['comment_body']['und'][0]['#title'] or
$form['comment_body']['und']['#title'] or
trying to set the values inside hook_after_build.

Strange since ALL the other labels can be changed in the hook_form_alter.

Then I tried the method : template_preprocess_comment(&$vars)
but it is never invoked NOR is the comment template.

Please understand that because I live in Quebec, I can not have an english label.
I would get sued by the Language Police lol.

Well I guess i'll use Javascript!

jbd44’s picture

Accessing $form['comment_body']['und'][0]['value']['#title'] allowed me to change the label.

prins310’s picture

Same problem here. 24ma13wg could you please elaborate on how you managed to get

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

to work? What is the full syntax of your function? And which file did you put the code in? template.php?

Many thanks in advance!

prins310’s picture

Managed to change the label thanks to the solution provided in another thread.

Go to the node / content type administration of the node / content type you want to adapt the label --> Go to "Comment fields" --> edit comment body --> change or "translate" the label of the comment body to your linkings.

For a site in a single non-English language this should do.

See post #4 by 4kant at:

http://drupal.org/node/1691780

With a big thank you to 4kant!

jbd44’s picture

@prins310 place in template.php

/**
 * Implements hook_form_FORM_ID_alter.
 */
function YOURTHEME_form_comment_form_alter(&$form, &$form_state) {
	$form['comment_body']['und']['0']['value']['#title'] = t('YOUR TEXT');
}
kiwad’s picture

In custom module :

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case 'comment_node_article_form':  // I use comments only in articles...
      $form['author']['homepage']['#access'] = FALSE;  //Use this if you want to hide the Homepage field
      $form['comment_body']['und']['0']['#title'] = t('Your comment'); //Use this to make the label translatable
      break;
  }
}
drupalerocant’s picture

Thanks Jose in #7!

I have been puzzilng my head for months on this issue.
More detailed for Article (for example)

  1. Structure-->Content type-->Article
  2. Go to comment fields
  3. Traslate the Label

That's it! thanks!

bcjmpr’s picture

#7 worked for me too, thank you!

dotoree’s picture

Issue summary: View changes

#7 was for me also, Thanks!

Anonymous’s picture

Oh man. Thanks.

I struggled with this for a minute.

anton.safin’s picture

@princ310 #13 Thanks, it works!

Molson_Ice’s picture

Thanks! Number 16 worked for me...even 4 years later ;)