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

Comments

nedjo’s picture

By 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.

SaxxIng’s picture

Yes... 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

SaxxIng’s picture

I 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

merlinofchaos’s picture

Project: Views (for Drupal 7) » Content Construction Kit (CCK)
Version: 6.x-2.2 » 6.x-2.x-dev
Component: node data » Views Integration

That's almost certainly CCK then.

markus_petrux’s picture

CCK 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?

vasike’s picture

subscribe

SaxxIng’s picture

Maybe it just happens with CCK fields not implemented in CCK distribution?

No, 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

amitaibu’s picture

subscribe

mishoboss’s picture

Yes, 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?

SaxxIng’s picture

Well, 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

sersim’s picture

I've fixed it replacing line 560 of views/theme/theme.inc (version 1.72 2009/04/08 04:24:52) with this one:

      $widget->label = t($info['label']);

So you can enter the english label, and it will be translated into italian.

lamp04ka’s picture

sersim, it is a great and so simple solution! Thank you very very much

andypost’s picture

Project: Content Construction Kit (CCK) » Views (for Drupal 7)
Component: Views Integration » Code
Status: Active » Needs review
StatusFileSize
new694 bytes

As proposed #11 patch

Cck should give untranslated info about fields so views can translate but maybe before _preprocess

Anyway need review of views maintainers

intyms’s picture

subscribe

merlinofchaos’s picture

Hmm. 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.

czeky’s picture

subsribing

andypost’s picture

@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.

halfiranian’s picture

I 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

merlinofchaos’s picture

Status: Needs review » Needs work

As I said, Views translates upon load, not upon display. And this definitely won't work right with the translation patch that is in progress.

criscom’s picture

@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.

pixelpreview@gmail.com’s picture

subscribing

Anonymous’s picture

same request

ilw’s picture

subscribing

giorgosk’s picture

Patch 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

rburgundy’s picture

I 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.

Toktik’s picture

Same problem #25. I have CCK-2.6 and Views-2.8.

Toktik’s picture

Status: Needs work » Active
bjcool’s picture

Subscribe.

I also need to translate the field label and "rewrite field output text" added via the Views admin UI.

adrianmak’s picture

same issue as of #25

intyms’s picture

Status: Active » Fixed

Everything 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.

intyms’s picture

Status: Fixed » Active
StatusFileSize
new10.78 KB

reopening, because it works only if you choose Custom Label.
it doesn't work if you choose Widget Label.

merlinofchaos’s picture

Status: Active » Fixed

Widget labels are provided by CCK, and must be translated by CCK. Views can't translate them.

taote’s picture

Status: Fixed » Active

I 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.

merlinofchaos’s picture

Status: Active » Closed (won't fix)

Why is it that today everyone is smarter than me?

Widget labels are provided by CCK, and must be translated by CCK. Views can't translate them.

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?).

merlinofchaos’s picture

I 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.

taote’s picture

Sorry, 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.

markus_petrux’s picture

In 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.

ayalon’s picture

Hi 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?

markus_petrux’s picture

After 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.

gremy’s picture

Status: Patch (to be ported) » Closed (won't fix)

At line 210 in "view/theme/theme.inc" in function template_preprocess_views_view_fields() you can replace:

      $object->label = check_plain($view->field[$id]->label());

with:

      if(function_exists('locale') && $language->language != 'en') {
        $object->label = locale(check_plain($view->field[$id]->label()), $language->language);
      } else {
        $object->label = check_plain($view->field[$id]->label());
      }

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();

gremy’s picture

Status: Closed (won't fix) » Patch (to be ported)
StatusFileSize
new1.89 KB

Here's the patch for this issue. Please review it.

gremy’s picture

You 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.

dawehner’s picture

Status: Closed (won't fix) » Patch (to be ported)

Can 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.

not even a custom inputed label was traslated.

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.

gremy’s picture

Thanks 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.

gremy’s picture

Status: Patch (to be ported) » Closed (won't fix)

Based on http://drupal.org/node/356951#comment-2954942, I am setting this back to won't fix. Sorry, my mistake.

rob c’s picture

#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)

josepvalls’s picture

Hello!

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:

  foreach ($columns as $field => $column) {
    // render the header labels
    if ($field == $column && empty($fields[$field]->options['exclude'])) {
      $label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : '');
      // HACK
      global $language;
      if(function_exists('locale') && $language->language != 'en'){
        $label = locale($label, $language->language);
      }
graham leach’s picture

There'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']);
}