User login

Views titles and text and i18n, a preliminary preface to a dirty hack

Internationalization module (i18n) now supports views in a way-- unfortunately I think it hard wires in the

sure how well that works with the preferred "show current language and no language" setting.

And there's still no goddamned "show in the user's preferred language if available, if not in the default language." That's what we need. There shouldn't even be a conceptual hack of "no language" – content is either in a language or it isn't. But all that's another story.

Views.module is not compatible with i18n
http://drupal.org/node/65722

Integration of i18n and views.module = fix translatablity of views
http://drupal.org/node/64004

And the one we're trying to deal with:

i18n Translation and Views: Header/Footer
http://drupal.org/node/89100

A workaround that involves hacking views is offered by JordiTR (May 17, 2006):

I've been facing that trouble on the last two weeks, asking everywhere without solution and it's neither a views.module nor a i18n.module. There are two issues easy to solve:

- the content: needs that you play with Content selection mode on the i18n configuration page, what works best for me is Only current language and no language

- the block title: I've customized the views.module with an extremelly small hack which consists on changing on line 1067 (function views_view_block($vid)) the expression $block['subject'] = '$view->title'; with $block['subject'] = t($view->title); that forces your custom name to that concret view to pass through the locale translator of strings; form here on, after the first time you load that view on your optional language it will add an entry on the locale table which will ready to be translated (and it works!!!) :-)

As far as I know there's no solution in Drupal 5 either.

Places like this will use the tt() function in Drupal 6 for dynamic translatable strings, and maybe this is in the experimental i18n modules Agaric turned off on WSF because they broke the ability to rename custom content (CCK) types.

If we patch views, can we at least do it right and use a call to tt() instead of t() ?

Resolution

Searched words: 
drupal translate views locale localization

Comments

Dirty hacks preferred to

Dirty hacks preferred to experimental i18n modules. This change made to

/**
* This views a view by block. Can be used as a callback or programmatically.
*/
function views_view_block($vid) ...

around line 435 (Drupal 5, final version of Views 1)

  if ($content) {
    $block['content'] = $content;
// original:
//    $block['subject'] = filter_xss_admin(views_get_title($view, 'block'));
// replacement...  this is oh so wrong
    $block['subject'] = t(views_get_title($view, 'block'));
    return $block;
  }

More subtle and simple solution

Because views can be manipulated in the views argument area you can add this there to solve the problem...

$views->page_title = t($views->page_title);

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.