translate title / i18n
miiimooo - August 6, 2009 - 13:01
| Project: | Faceted Search |
| Version: | 6.x-1.0-beta2 |
| Component: | User interface |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
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']));
}
}
?>
#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
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:
<?phpfunction 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));
}
}
?>