function i18n_block_block_list_alter in Internationalization 7
Implements hook_block_list_alter().
Translate localizable blocks.
To be run after all block visibility modules have run, just translate the blocks to be displayed
File
- i18n_block/
i18n_block.module, line 91 - Internationalization (i18n) submodule: Multilingual meta-blocks
Code
function i18n_block_block_list_alter(&$blocks) {
global $theme_key, $language;
// Build an array of node types for each block.
$block_languages = array();
$result = db_query('SELECT module, delta, language FROM {i18n_block_language}');
foreach ($result as $record) {
$block_languages[$record->module][$record->delta][$record->language] = TRUE;
}
foreach ($blocks as $key => $block) {
if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
// This block was added by a contrib module, leave it in the list.
continue;
}
if (isset($block_languages[$block->module][$block->delta]) && !isset($block_languages[$block->module][$block->delta][$language->language])) {
// Block not visible for this language
unset($blocks[$key]);
}
}
}