I have a custom node type
When creating that node I get the label of that field perfectly translated by localizer (the locale is Greek)
When I save and view the node that field label is shown in English again (the locale is Greek)

CommentFileSizeAuthor
#4 cck_t_labels_0.patch1.59 KByched

Comments

giorgosk’s picture

After some further investigation it seems that the only things that got translated from the CCK fields are the "text > text fields" CCK fields ( I have also some "Integer > text field" CCK field that does not translate.

Mind you the translation is only happening when I edit the node (on view the default language, english is displayed)

Just in case you were wondering tranlated string is done trough the Locale interface (admin/settings/locale manage strings)

related posts
there is some talk about it
http://drupal.org/node/117256 (similar localizer issue)
and
http://drupal.org/node/117474 (CCK translation support request)

huayen’s picture

How did you get CCK field label translated? I tried a text field and can not see any 'locale' or 'translate' tab in the configuration...

giorgosk’s picture

before I was referring to admin/settings/locale > manage strings and search and translate the string to be translated (the label name of your cck field in this case) you have to have Localizer (it probably works with I18n) and Locale enabled

when you edit the node the the CCK field labels should be translated to the correct locale

----------------------------
BUT,

I have actually found a solution to this if you are interested here it goes

1. drop the field.tpl.php and template.tpl.php from the modules/CCK/theme folder to your themes folder
(if template.tpl.php already exists just copy the contents in)
2. change the first line of field.tpl.php so it reads like this (I added the $label = ...)

 <?php if (!$field_empty) : $label = t($label); ?>

3. that's it

Apparently it works with drupal cache on or off
And you can even search the cck field contents ( ???????? )

yched’s picture

StatusFileSize
new1.59 KB

Displaying translated field labels is not a problem- simply a forgotten t().
Attached patch fixes it in the default theme_field function, and in the 'example' template.php for custom field theming.
(patch is for 5 branch, should apply easily on 4.7)

Once again, translation isues for _values_ is a whole other story.
Content translating is the scope of i18n / localizer modules.

(followup to the discussion in http://drupal.org/node/117474) Karen, I think there is no problem regarding the page cache. On a vanilla drupal install, anonymous users see the pages in the default language defined in core locale.module settings. If a site has multiple languages for anonymous users, then it has to use i18n / localizer, which (i think) handle the language in the url, so it's OK wrt page cache.

yched’s picture

Status: Active » Needs review

Oh, and it could use some review - mainly on the 'custom field templates' area :
Not sure whether it's best to t() the label in phptemplate_field(), or in the field.tpl.php file...

yched’s picture

Status: Needs review » Fixed

I committed a slightly different of the default theme_field function to display the translated version of the field label, and updated the theming examples in cck/theme

Anonymous’s picture

Status: Fixed » Closed (fixed)