Translate View More/Less text in Facet Blocks in Drupal 7

Enable facet_bonus block. Then you will have hook_facet_items_alter. To enable the hook you need to go to configuration of facets and click on the facet configure filter and enable rewrite call back function.

Example Code


<?php

/**
* Implements hook_facet_items_alter().
*
* Translate facetblock strings.
*/
function module_name_facet_items_alter(&$build, &$settings) {
$facet_trans_set = array(
'search_api@custom_solr_index:block:field_custom_text',
);
if (in_array($settings->name, $facet_trans_set)) {
$settings->settings['facet_more_text'] = t($settings->settings['facet_more_text']);
$settings->settings['facet_fewer_text'] = t($settings->settings['facet_fewer_text']);
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s