I am trying to edit a .tpl.php to print some cck fields. I have activated CCK translation in the site and I have edited CCK strings.
I have no problem with translated cck content, as using content_format works smoothly and content is translated correctly.
But I can't see how to print the translated cck label for the field. I think I must be using tt() but I see in the code:
@param $name
* Textgroup and location glued with ':'.
function tt($name, $string, $langcode = NULL, $update = FALSE) {
I have tried using
print tt('cck:field:user-field_edad:title',$node->content['field_edad']['field']['#title'],i18n_node_get_lang($node->nid),FALSE);
But I still see the string in its original language. In Spanish I should read edad, while in english I should read age. But no way, I am always reading edad, no matter english or spanish. But content is properly translated.
I think there should be more documentation on this matter of "Textgroups and locations".
Comments
Comment #1
Farreres commentedOk, I found by myself. Will explain the solution.
First, in order to know the name to put in tt function, you must go to translation interface, look for the string, and there you'll find the info. First column is text group, second is string and below you'll see some text with several : characters. Text group must be preceded with a : to the rest.
For example, first and second comuns could read:
Text group | string
CCK . . . . . | Edad
. . . . . . . . | field:user-field_edad:widget_label
Then in order to show the translated label you need this piece of php code:
$field = content_fields('field_edad', $node->type);
print tt('cck:field:user-field_edad:widget_label',$field['widget']['label']) // name is text group : string
I hope I can help someone with this. It took me weeks to find.
Comment #2
Farreres commentedComment #4
angeloo commentedHello,
I've got a website in English and French, field title are printed in french but not in English.
Is there something i missed?
Thanks
Angelo