Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm quite sure I'm missing something, but I'm not able to translate "Title" and "Body" fields although now could be defined by user.
I'm on a drupal 5.1 with i18n but as far as are interface strings I thought it need to be done by locale...
I dig into the code and I found that they are defined without t(). In node.module around line 2957 you can see:
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5,
);
Is it right? or need to be translated as...
$form['title'] = array(
'#type' => 'textfield',
'#title' => t(check_plain($type->title_label)),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5,
);
Same happens with body, that I changed for:
'#title' => t(check_plain($type->body_label)),
I did the change and I didn't noticed any collateral effects.
Sorry in advance for the annoyance if it's not a bug and it's just my ignorance.
Cheers,
m.
Comment | File | Size | Author |
---|---|---|---|
#4 | translate_node_fields_d7.patch | 1.28 KB | lilou |
#1 | translate_node_fields.patch | 919 bytes | flk |
Comments
Comment #1
flk CreditAttribution: flk commentedsince your able to define both title and body shouldn't you be defining them in the chosen language?
any way's, you cant change anything in a stable version...
btw in future you should create a patch for the problem in this format attached. (either use diff or something like tortoiseCVS)
Comment #2
mbria CreditAttribution: mbria commentedNo problem with attaching a patch. I will do next time... but I was unsure about if it really was an issue. Thanks to fix it.
> since your able to define both title and body shouldn't you be defining them in the chosen language?
Sure, but the point is that in a multilang site, you could need labels in different languages (based on user's preference) so I believe this also need to be translated.
My concern about this patch is related with the way locale works.
When adding url is allways "*/node/add" but what will happen when editing and the url changes?
Translating it here means that a new record will be added for every edited node?
Once again, sorry if it's just my ignorance.
Comment #3
chx CreditAttribution: chx commentedComment #4
lilou CreditAttribution: lilou commentedReroll
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedThe last submitted patch failed testing.
Comment #6
strellman CreditAttribution: strellman commentedWell I started to update this report as a bug and then found out how to make it work but not work well. This is actually done with string translation in the i18n or internationalization module http://drupal.org/project/i18n as described at http://drupal.org/node/313293
Try going to /admin/build/translate/refresh
selecting content type
(I saw the following...)
Updated string group:title for textgroup nodetype: Name of group
Updated string group:title for textgroup nodetype: Action plan (This is my body field in English)
Since I couldn't find the title to translate I changed back the field labels to "Title" and "Body"
This time it took my translation for Text group - content type, and in the string column - Body / group:title so that the original text was "Body". For my Romanian translation I typed "Group Action Plan" which actually showed up as the label for the Title field instead of the Body field. Very strange!
Comment #7
Jose Reyero CreditAttribution: Jose Reyero commentedThese issues are fixed in latest -dev, refresh locales after updating
Comment #9
noelbush CreditAttribution: noelbush commentedPrior to your next release (to avoid using a dev version of this complex module), here is a very simple module that just addresses this problem:
http://drupal.org/project/trans_core_labels