Project:Faceted Search
Version:6.x-1.0-beta2
Component:User interface
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

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

#1

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.

#2

Status:active» needs review

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:

<?php
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));
  }
}
?>
AttachmentSize
faceted_search_ui.module-i18n-title.patch 525 bytes

#3

Title:translate title / i18n» translate title and facets

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

AttachmentSize
faceted_search_translate.patch 908 bytes

#4

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.

#5

Status:fixed» closed (fixed)

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