function i18nblocks_preprocess_block in Internationalization 6
Implementation of hook_preprocess_block().
Translate blocks.
See also
File
- i18nblocks/
i18nblocks.module, line 247 - Internationalization (i18n) submodule: Multilingual meta-blocks
Code
function i18nblocks_preprocess_block(&$variables) {
global $language;
$block = $variables['block'];
// Replace menu blocks by their translated version.
if (module_exists('i18nmenu')) {
if ($block->module == 'menu') {
$block->content = i18nmenu_translated_tree($block->delta);
if ($block->subject && empty($block->title)) {
$block->subject = i18nstrings_string('menu:menu:' . $block->delta . ':title', $block->subject);
}
}
elseif ($block->module == 'user' && $block->delta == 1) {
$block->content = i18nmenu_translated_tree('navigation');
}
}
// If the block has language, do nothing, it is suppossed to be translated
$havelanguage = _i18nblocks_list($language->language);
if ($havelanguage && isset($havelanguage[$block->module][$block->delta])) {
return;
}
else {
$variables['block'] = i18nblocks_translate_block($block);
}
}