In the last couple of years, there were quite a lot of posts on the problem of label translation for the list of allowed CCK field values (see e.g. http://drupal.org/node/182884 or http://drupal.org/node/248573);
with newer versions of Drupal, CCK, and i18n released since then, this problem still does not seem to be fully resolved.
For example, I create a text CCK field for countries that should be selected from the "Value|Label" list:
AL|Albania
AM|Armeniaand so on.
Then, I'm trying to translate country names into another language.
I go to admin/build/translate/search and search for 'Albania' string - but I cannot find it.
I do "Refresh strings", I run cron, I dance with a tambourine - but I still cannot find it.
Okay, let's try to use an old trick of assigning label strings via a php code:
return array(
'AL' => t('Albania'),
'AM' => t('Armenia')
);This seems to work better, and in most cases I am able to find the strings to translate.
Sometimes, however, it does not work either. It may help if you edit and save a node that refers to this CCK field - then, you are usually able to find a string that was not found before. (This also works better for php code than for the regular way of defining value labels).
To cut a long story short, translation of value labels often seems to require some creative efforts instead of being a routine procedure.
Does anybody know - is this a locale issue, or i18n issue, or cck issue?
Comments
Comment #1
jose reyero commentedThis behavior you describe is consistent with Drupal 6 not translating user defined strings.
So this may be a feature request for i18n, cck, or both. For now, it's in the 'to-do' list.
Comment #2
SaxxIng commentedI'm interested too to this feature... essentially it is a behavior like the selected fields in core profile (that are correctly translatable with the i18nprofile). To Implement this type of feature, at the moment, the major problem/limit is in 18n or in cck?
Regards,
Saxx
Comment #3
.jon commentedThis missing feature essentially means that you cannot supply a fully translated site, if you use custom CCK fields.
Or is there a way around this? (Displaying translated custom CCK field labels according to the node language)
Comment #4
amccann commentedI will be a sponsor of a fix for this if someone is interested in working on it.
Comment #5
Cactii1 commentedI've tried with the code but it doesn't seem to work for me.
Going to be playing with this for awhile it seems.
EDIT
Forget it - this is not possible.
Going to have to go with a database for each language.
Careful uninstalling anything that has to do with Multi-Language stuff. Totally broke my site and left my database a complete mess.
Comment #6
jakosa commentedOoops. Not good. Hope this will be fixed nicely soon.
Comment #7
Vote_Sizing_Steve commentedsubscribing
Comment #8
iernst commentedi would like to be a sponsor too, if this will be fixed.
Comment #9
yesct commentedsubscribing.
Comment #10
peterpoe commentedMy workaround (just for labels) is to change the t() functions in content-field.tpl.php from this:
t($label)to this:
t($label, array(), $node->language)Now the labels have the same language of the node.
Comment #11
alonpeer commentedSubscribe
Comment #12
ErwanF commentedSubscribing. I can hardly believe this.
Comment #13
jose reyero commentedI think they finally added t() to titles and descriptions in CCK, so this may not be an issue anymore.
Comment #14
Daniel Norton commentedsubscribe
Comment #15
sandino commentedsubscribe
Comment #16
merilainen commentedsubscribing
Comment #17
headkit commentedtextfields should be translatable like body-text i think.
subscribing and hoping...
Comment #18
neochief commentedMarking this as duplicate of #531662: Internationalization support, as there posted complete solution.
Comment #19
cangeceiro commentedThis works if you get the translation table module, then go to "Site Building" > "Translate Interface" > "Search" and search for the label of your cck fields, translate here and the fields display properly.
Comment #20
vronkdaut commentedI am not able to translate my cck-field labels.
I tried to import the translations and also to translate individual label in the translate interface.
But they still show up in the original.
Anyone any idea where I could look for remedy?
This should be working, right?
I mean, there is
t($label)in content-field.tpl.php.Does it need more?
EDIT: sorry, mea culpa. haven't updated cck-module. with 2.6 version it works fine.
thanks
Matej
Comment #21
Village Internet commentedIn Views, use a custom field label and this can be translated
Comment #22
webel commentedI have Content 6.x-2.6, and I still can't get the translated field labels to show up on loading translated pages.
I have translations entered for the field labels in the translate interface (found using search as described above).
Is there anything else one had to do ?
What else can I check ?
Comment #23
webel commented@peterpoe who wrote:
I did this and got no change, vs Content 6.x-2.6.
Comment #24
druvision commented#21 saved my day! Works for me beautifully. "In Views, use a custom field label and this can be translated".
Comment #25
cholden commented#21 / #24 - How do you translate a custom field label?
Comment #26
arnulfo commentedHi, try (see #19):
Refresh strings:
... admin/build/translate/refresh
snd search string:
... admin/build/translate/search
Comment #27
tomsm commentedHow can I translate prefix and suffix?
Comment #28
fleshgrinder commentedTo translate the allowed values of a CCK field you have to use the PHP code form and do the following:
In the object
$languageis always the currently displayed language stored, so even if the field is displayed in another context it will be translated correctly.Comment #29
momper commentedsubscribe
Comment #30
pendashteh commentedmy solution for translating values:
find the file views-view-field.tpl.php, copy it in your theme directory.
then change:
to:
Comment #31
gabrielu commentedI still didn't found how to translate prefix and suffix texts to CCK fields. Any hints? Is there a .tpl for displaying the field edit / view wrapper, where I could do the same trick as with views-view-field.tpl.php?
Although I would love a more specific approach, more like:
replace
with:
rather than translating the whole $output variable.
Thanks,
Gabriel
Comment #32
Drake commentedsubscribe
Comment #33
gabrielu commentedHello,
I finally ended up in theming the textfield element.
Placed in my template.php file
Comment #34
KhaledBlah commented@takpar (#30) Thanks, I was looking for that!