I have a View field of which the content is well translated, but the block title ("Articles" for instance) remains untranslated for some reason, eventhough these have been translated through Drupal's "Translate interface" UI.

What could be the problem here?

Attch: views export

Comments

knalstaaf’s picture

Title: Block titles are not being translated » Block titles not translated
Status: Active » Closed (fixed)

Adding the t-function around the title output does the trick (viewfiled/viewfield.module, around line 218).

<?php

function theme_viewfield_formatter_default($variables) {
  $element = $variables['element'];
  $view_title = $element['#view_title'];
  $view_output = $element['#view']->preview($element['#view_display'], $element['#view_arguments']);
  return '<div class="viewfield-wrapper"><h2 class="view-title">' . t($view_title) . '</h2><div class="view-output">' . $view_output . '</div></div>';
} 

?>

Source of code: #281409: Show view title in viewfield output

knalstaaf’s picture

Status: Closed (fixed) » Reviewed & tested by the community
knalstaaf’s picture

Status: Reviewed & tested by the community » Needs review

Hold on, adding the t-function shows the word "Array" on translated blocks with no title??

<?php
<h2 class="view-title">Array</h2>
?>
knalstaaf’s picture

Status: Needs review » Needs work
keithm’s picture

As I recall viewreference outputs the title. You may want to check how they do it for some guidance.

I also recommend adding a boolean setting for this to let the user turn titles on or off (at the instance level, see #1230534: allowed_views should be an instance setting, not a field setting).

jerdavis’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)