Community & Support

i18n Translation and Views: Header/Footer

I'm using views to make a list of nodes, filtering by the language chosen with i18n. This works great!

But I also want to translate the View's Header and Footer, the text that appears before and after the list. Right now I can't figure out anyway to do this besides creating a separate view.

I'm having this same problem with some of the other modules as well, for instance the contact form. Translation works fine on the form labels, but I don't know how to translate the instructions in the form header.

Can anyone think how to do this? Thanks

Comments

t() function

Hi tkrebs, probably your problem is based on the fact that views has not considered to use the t() function to use l10n (localization module) to translate those elements. I've found that on the title of blocks created by views.module on 4.7 and I already found that on the 4.6 version. Look on the code on the parts that create those header and footer elements and add that function.

More info

You'll find a deeper discussion on that thread: 64004.

so, whats the recommended

so, whats the recommended way to do this?

t($view->page_header) doesn't work

Workaround: Translating Views

Current language code

To get the current language code in 6.x

global $language;
$lc = $language->language;

Simple solution

To translate Views Header I use such simple snippet (Drupal 6.x):

<h1><?php
   
global $language;
   
$lc = $language->language;
    if (
$lc=="en") print "Photo Gallery";
    if (
$lc=="ru") print "Фотогалерея";
    if (
$lc=="be") print "Фотагалерэя";
?>
</h1>

Hi, does this still work with

Hi,
does this still work with views2 and D6?
greetings,
Martijn

My preferred solution is

My preferred solution is Language Sections.

Drupal consulting and development, multi-language specialists netgenius.co.uk

I'm using Views3, it does add

I'm using Views3, it does add t() around footer/header. But now my problem is that I have html in my header text, which isn't allowed for translation.

<div class="item-list"><ul><li> <a href="node/add/blog">Create new Hobby entry</a> </li></ul></div>

The submitted string contains disallowed HTML: <div class="item-list"><ul><li> <a href="node/add/blog">Добавить запись Хобби</a> </li></ul></div>

So I wonder if there's another way to translate the text only, and add HTML somehow?

I can confirm above

I can confirm that, it's definitely a problem. You can use different input filters in header/footer and it's more than likely to have html there, or even PHP code. In combination with Features and translations export things can easily mess up. There should be a options to disable unwanted translations.

nobody click here