Index: i18nviews/i18nviews.module =================================================================== --- i18nviews/i18nviews.module (revision 1516) +++ i18nviews/i18nviews.module (working copy) @@ -149,3 +149,38 @@ } return $links; } + +/** + * Implement hook_form_alter to localize exposed forms + * + */ +function i18nviews_form_alter(&$form, $form_state, $form_id) { + if ($form_id != 'views_exposed_form') return; + + // Localise taxonomy terms + foreach(element_children($form) as $key) { + if (preg_match('/^tid_\d+/', $key) || + preg_match('/^term_node_tid_depth_\d+/', $key)) { + foreach ($form[$key]['#options'] as $index => $opt) { + foreach ($opt->option as $opt_key => $opt_value) { + $prefix = ''; + if (preg_match('/^(-+?)(.*)$/', $opt_value, $matches)) { + $opt_value = $matches[2]; + $prefix = $matches[1]; + } + $form[$key]['#options'][$index]->option[$opt_key] = $prefix . tt("taxonomy:term:$opt_key:name", $opt_value); + } + } + } + } + + // Localize labels + if (!empty($form['#info'])) { + foreach(element_children($form['#info']) as $key) { + if (!empty($form['#info'][$key]['label'])) { + $type = preg_replace('/_\d+$/', '', $key); + $form['#info'][$key]['label'] = tt("views:exposed:$type", $form['#info'][$key]['label']); + } + } + } +}