Looks like the title gets partly translated. For instance I get News: Afrique du Nord. I can see where it could be changed but I'm not sure what it needs changing to. Should it be tt() if 18n is available?

faceted_search_io.module, 752

function faceted_search_ui_set_title($env) {
  $labels = array();
  if ($env->get_text()) {
    foreach ($env->get_filters() as $filter) {
      if ($filter->is_active()) {
        $category = $filter->get_active_category();
        // Note: get_label() is responsible for filtering its returned string.
        $labels[] = $category->get_label(FALSE);
      }
    }
  }
  if (count($labels)) {
    drupal_set_title(t('@title: !terms', array('@title' => $env->settings['title'], '!terms' => implode(', ', $labels))));
  }
  else {
    drupal_set_title(check_plain($env->settings['title']));
  }
}

Comments

miiimooo’s picture

Sorry for bumping this - let me explain a bit more. I currently get the bizarre result where the terms are translated but the title isn't. Should be easy to fix but I don't see how. As I wonder why the terms are correctly translated.

miiimooo’s picture

Status: Active » Needs review
StatusFileSize
new525 bytes

Okay I think I understand how to do this in an i18n way. Here is a possible patch. Note that I'm using an already slightly patched version of the file so let me know if the patch doesn't work. Basically, what it does is this:

function faceted_search_ui_set_title($env) {
  $labels = array();
  if ($env->get_text()) {
    foreach ($env->get_filters() as $filter) {
      if ($filter->is_active()) {
        $category = $filter->get_active_category();
        // Note: get_label() is responsible for filtering its returned string.
        $labels[] = $category->get_label(FALSE);
      }
    }
  }
  $title = $env->settings['title'];
  if (function_exists("tt")) {
    $title = tt("faceted_search:title:$title:name", $title);
  }
  if (count($labels)) {
    drupal_set_title(t('@title: !terms', array('@title' => $title, '!terms' => implode(', ', $labels))));
  }
  else {
    drupal_set_title(check_plain($title));
  }
}
jcnventura’s picture

Title: translate title / i18n » translate title and facets
StatusFileSize
new908 bytes

Hi,

I've just discovered that the environment title and the facet label seem to be the only items that are not translated. The above patch makes the module depend on i18nstrings, which is overkill to the specific problem. The patch included here does not include that dependency and simply wraps the title and facet label in t() calls.

I've tested all the different UI blocks and forms and everything else was translated.

João Ventura

david lesieur’s picture

Title: translate title and facets » Translate environment title
Status: Needs review » Fixed

@jcnventura: The documentation for t() clearly states: custom data from user input or other non-code sources should not be passed through t(), so using i18nstrings as proposed by miiimooo is the right way to translate environment names. Similar code is already present in the dev version of Faceted Search.

Translating facets is a separate issue that needs a specific solution for each type of facet, otherwise t() might get called twice on the same text. A specific solution for CCK facets has been committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.