Hi,
I'm not sure if this is a bug or simply a not implemented (yet) feature, but I'll try to get info/support about.
I have a site with two languages and all views works well (I use also CCK 2.1 and i18n) . The only problem is the labels of the fields (either the simply viewed fields and the labels of the exposed filters). For this labels exist the correspondingly translate version in db (if I simply view the node in different languages, all the labels are correctly translated). Generally I use to display "Widget label", but the problem arise also if I try to personalize the label.
Also a note: on my site the default language is not English, but Italian (but this isn't a problem in general... so I hope this isn't neither for Views modules).
Thanks a lot to everyone can tell me something on this "problem" and obviously thanks a lot to the "Views team" for their incredible work!
Regards,
Saxx
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | views-[356951].patch | 1.89 KB | gremy |
| #31 | views-custom-label.jpg | 10.78 KB | intyms |
| #13 | views_label_D6.patch | 694 bytes | andypost |
Comments
Comment #1
nedjoBy labels, do you mean the labels of CCK fields as customized via the CCK UI? If so, this may be a CCK rather than a Views issue.
Comment #2
SaxxIng commentedYes... this labels! I asked support in "Views" because the translated labels are correctly used everywhere (i.e. on pages and so on) and only in Views are not displayed translated.
I'll try to ask to CCK team also!
Thanks,
Saxx
Comment #3
SaxxIng commentedI have done more tests and I have discovered that only "widget" labels are not translated. If I personalized the labels in "Views", this are correctly translated.
I'll try to do more test and ask support to CCK team also.
Regards,
Saxx
Comment #4
merlinofchaos commentedThat's almost certainly CCK then.
Comment #5
markus_petrux commentedCCK builds default views integration in includes/views/content.views.inc, function content_views_field_views_data(). And that used t() to wrap field labels in 'title' and 'title short' items of the exposed views columns.
Maybe it just happens with CCK fields not implemented in CCK distribution?
Comment #6
vasikesubscribe
Comment #7
SaxxIng commentedNo, not only! It happens also with standard cck field types (text, numbers, nodereference ...).
At the moment I have resolved the problem using custom labels for every field, instead of "widget". Unfortunately exposed labels aren't translated also in this case.
Saxx
Comment #8
amitaibusubscribe
Comment #9
mishoboss commentedYes, I also have the same question - is it a bug or not implemented function? I thing it's a Views issue, couse it happens only in Views.
SaxxIng, how exactly did you resolve it?
Comment #10
SaxxIng commentedWell, I have not exactly resolved... I have only used an uncomfortable workaround. When I create a View, I chose the fileds I want to view, and foreach I use a "Custom Label" instead of "Widget Label". After that I can translate this labels with the usual translation interface. The big problem is that the labels of Exposed filters are not translated (neither with this trick).
Regards,
Saxx
Comment #11
sersim commentedI've fixed it replacing line 560 of views/theme/theme.inc (version 1.72 2009/04/08 04:24:52) with this one:
So you can enter the english label, and it will be translated into italian.
Comment #12
lamp04ka commentedsersim, it is a great and so simple solution! Thank you very very much
Comment #13
andypostAs proposed #11 patch
Cck should give untranslated info about fields so views can translate but maybe before _preprocess
Anyway need review of views maintainers
Comment #14
intyms commentedsubscribe
Comment #15
merlinofchaos commentedHmm. I'm not sure Views should be translating the label at this point. Normally Views translates its own data upon load. Data given to it from an external source should already be translated, or we will end up translating labels multiple times.
Comment #16
czeky commentedsubsribing
Comment #17
andypost@merlinofchaos cck widget brings not only data but a descriptive metatada about, suppose label should be translated at rendering time so data in memory can be reusable.
Comment #18
halfiranian commentedI think the point is this is not only about CCK, right?
My exposed filter labels are not translatable. So 'Filter by tag:', one of my exposed filters, is not translatable.
I'll try patch in #13
Comment #19
merlinofchaos commentedAs I said, Views translates upon load, not upon display. And this definitely won't work right with the translation patch that is in progress.
Comment #20
criscom@merlinofchaos: even if the cck-lables have a translation, views only show their original version. as a result i have the original lables and their translated content which is a mixture of two languages.
labels-do-not-appear-in-the-translation-in-views
alas, i am not a php expert and do not want to fiddle with the view module. on the other hand i think it cannot be that difficult changing this. or maybe this is a feature request?
generally, i think views is one of the best modules out there and boosts drupals power by lightyears.
a reply would be very much appreciated.
Comment #21
pixelpreview@gmail.com commentedsubscribing
Comment #22
Anonymous (not verified) commentedsame request
Comment #23
ilw commentedsubscribing
Comment #24
giorgoskPatch from #531662: Internationalization support has been committed to
CCK 7.x-2.x-dev 2009-Sep-04
and
CCK 6.x-2.x-dev 2009-Oct-15
and solves this problem
NOTE: CCK 2.5 does not include the patch
Merlin was right it was a cck related issue thus marking this as fixed
Comment #25
rburgundy commentedI am still experiencing this issue. I created a cck text field originally with label in English and then in Translation Table I set the French and English translations, but when viewing the Views page in French it still shows the label in English.
Site default language: French
Also enabled language: English
Should I be making the cck field originally in French instead of English?
In translation table I see:
Original | French | English
apple | pomme | apple
The Views page shows 'apple' even if the language is set to French.
Comment #26
Toktik commentedSame problem #25. I have CCK-2.6 and Views-2.8.
Comment #27
Toktik commentedComment #28
bjcool commentedSubscribe.
I also need to translate the field label and "rewrite field output text" added via the Views admin UI.
Comment #29
adrianmak commentedsame issue as of #25
Comment #30
intyms commentedEverything works well on my side.
I am using:
Drupal 6.16
Views 6.x-2.10.
If something is not working go to "admin/build/translate/refresh"
and "refresh strings" + "update translations".
then go to "/admin/build/translate/search" and check if the translations are ok.
clear drupal cach (go to "admin/build/themes" and press save button).
now check your views. everything has to be ok.
Comment #31
intyms commentedreopening, because it works only if you choose Custom Label.
it doesn't work if you choose Widget Label.
Comment #32
merlinofchaos commentedWidget labels are provided by CCK, and must be translated by CCK. Views can't translate them.
Comment #33
taote commentedI have the same problem. When I choose Custom Label it´s translated, but not with Widget Label. Reopening because on the normal display of a node of that content type node the label of that CCK it´s translated correctly.
Comment #34
merlinofchaos commentedWhy is it that today everyone is smarter than me?
Which am I?
1) Wrong
2) Lying
Because I thought my explanation was clear and unambiguous. If 1) please explain why I am wrong (and no, just because data is displayed within Views does *not* mean Views is responsible for that data. You don't blame node.module for how CCK fields are translated when viewing a node, do you?).
Comment #35
merlinofchaos commentedI will add a little bit more to my explanation.
Currently, Views translates on load. (Note: Yes we know this is not good. There's work to improve this). However, when selecting 'widget', CCK provides this value dynamically. Views is not able to translate this value. CCK must provide the translation when it sets the label.
Comment #36
taote commentedSorry, I didn't understand very well your previous answer. I wasn't trying to be smarter than anyone. I'm sorry if you felt bothered by it.
Comment #37
markus_petrux commentedIn the hope to help those that may land here, still with problems with CCK field labels:
- Initially, CCK was translating field labels using t(), and it still does, but...
- Some time ago, integration with i18n was possible since #531662: Internationalization support and #531660: i18n + CCK. In addition, support for CCK stuff was added to Translation Table module, see #499668: Possibility to integrate cck fields?.
Now, let's look at CCK integration for Views:
- The Views field handler implements the 'label' option as a translatable attribute.
- CCK fields use a Views handler that provides an option to choose how to generate the label of the field for Views. You can select from Node, Custom or Widget label.
- When you choose "Widget label", CCK passes to Views $field['widget']['label'], which is already translated if you have installed i18n stuff with support for CCK.
Comment #38
ayalon commentedHi markus_petrux
I ran into the same issue:
If I choose "Widget label" in the view, the label is not translatable.
I have read you post again and again, but I don't see a solution. Assumign I have views and i18n (views and cck translation acrivated).
How can I force the translation using the "Widget label" selection in views?
Comment #39
markus_petrux commentedAfter translating the CCK field labels and descriptions (recommended to use http://drupal.org/project/translation_table), you may need to clear the content cache, and maybe also the views caches.
Comment #40
gremy commentedAt line 210 in "view/theme/theme.inc" in function template_preprocess_views_view_fields() you can replace:
with:
and at the beginning of the function declare:
global $language;This should work. It works for me.
You can use a similar approach in function template_preprocess_views_exposed_form();
Comment #41
gremy commentedHere's the patch for this issue. Please review it.
Comment #42
gremy commentedYou are right over here. But in my tests (maybe I did something wrong), not even a custom inputed label was traslated.
But whatever the case, the posted patch should translate the field if it has a translation.
Comment #43
dawehnerCan someone explain why http://drupal.org/node/356951#comment-2954942 is not valid anymore?
Translation of views is really hard. Therefore this part will be written right for views3. It's definitive a much harder task then this simple patch.
Your patch might lead to an incredible amout of strings in the db if you have a dynamically changeing label.
I don't want to reset to reset but this is for me the real status of this issue.
That's afaik the case which don't need to be handled by cck. But anyway this has to be done good and not this hacky way.
Comment #44
gremy commentedThanks for the input. I reviewed my own code again and you are right:
* This is a hacky way!
* And it will generate strings in db, so do not use it.
It has to be done the propper way, and I hope it will be written right for Views3.
Comment #45
gremy commentedBased on http://drupal.org/node/356951#comment-2954942, I am setting this back to won't fix. Sorry, my mistake.
Comment #46
rob c commented#30 worked for me guys
updated from
drupal 6.16
cck 2.6
views 2.10
to
drupal 6.17
cck 2.7
views 2.11
then saved a node, didn't help, emptied the cache, didn't help, then stumbled upon #30, now it works like a charm. the theme page save fixed it. i already tried the rest.
only thing about the order: first i saved the theme page again, then emptied the cache, hope this helps
great work peeps!
(is this now working out of the box on a clean install? or do we have to follow #30 every time we create a label translation? not a problem if that's the case, just to be sure)
Comment #47
josepvalls commentedHello!
My setup is:
Drupal 6.20
CCK 6.x-2.8
Views 6.x-2.12
The way I went around this issue was following advice in #40 with some tweaks.
I know hacking is a bad practice and I should burn in hell, but if someone is in a hurry:
Around line 340 in theme.inc:
Comment #48
graham leach commentedThere's a helper function with a missing t() envelope.
Look in modules/views/handlers/views_handler_field.inc
For:
/**
* Get this field's label.
*/
public function label() {
if (!isset($this->options['label'])) {
return '';
}
// 2025-05-13-GL Enclosed in t() function to enable table heading translations
return t($this->options['label']);
}