Sorted this out.
The Sortby items defined in browse.conf would be shown in ca_browse_results_html.php as follows:
foreach($va_sorts as $vs_sort => $vs_sort_flds) {
$i++;
if ($vs_current_sort === $vs_sort) {
print "<li class='selectedSort'>($vs_sort)</li>\n";
} else {
print "<li>".caNavLink($this->request, $vs_sort, '', '*', '*', '*', array('view' => $vs_current_view, 'key' => $vs_browse_key, 'sort' => $vs_sort, '_advanced' => $vn_is_advanced ? 1 : 0))."</li>\n";
}
if($i < sizeof($va_sorts)){
print "<li class='divide'> </li>";
}
}
The challenge here is to get $vs_sort translated. This did the trick:
foreach($va_sorts as $vs_sort => $vs_sort_flds) {
$i++;
$translated_sort = _t($vs_sort); // Translate the sort label
if ($vs_current_sort === $vs_sort) {
print "<li class='selectedSort'>{$translated_sort}</li>\n";
} else {
print "<li>".caNavLink($this->request, $translated_sort, '', '*', '*', '*', array('view' => $vs_current_view, 'key' => $vs_browse_key, 'sort' => $vs_sort, '_advanced' => $vn_is_advanced ? 1 : 0))."</li>\n";
}
if($i < sizeof($va_sorts)){
print "<li class='divide'> </li>";
}
}
In this updated version, I introduced the _t() function:
$translated_sort = _t($vs_sort); // Translate the sort label
Now, instead of directly outputting $vs_sort, I'm calling _t($vs_sort) to:
- Pass the string stored in
$vs_sort to _t() (your translation function).
- Look up its translation in the
.mo file.
- Return the translated string (if a translation exists) and assign it to
$translated_sort.
Everywhere $vs_sortwould be used for output, I now use $translated_sort instead:
print "<li class='selectedSort'>{$translated_sort}</li>\n";
This ensures that translations are applied to the sort labels when they're displayed.
Hope this serves someone.