You are here

function i18n_taxonomy_form_all_localize in Internationalization 7

Localize a taxonomy_form_all() kind of control

The options array is indexed by vocabulary name and then by term id, with tree structure We just need to localize vocabulary name and localizable terms. Multilingual vocabularies should have been taken care of by query rewriting.

1 call to i18n_taxonomy_form_all_localize()
i18n_taxonomy_form_alter in i18n_taxonomy/i18n_taxonomy.module
Implements hook_form_alter().

File

i18n_taxonomy/i18n_taxonomy.module, line 955
i18n taxonomy module

Code

function i18n_taxonomy_form_all_localize(&$item) {
  $options =& $item['#options'];
  foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
    if (!empty($options[$vocabulary->name])) {

      // Localize vocabulary name if translated
      $vname = i18n_taxonomy_vocabulary_name($vocabulary);
      if ($vname != $vocabulary->name) {
        $options[$vname] = $options[$vocabulary->name];
        unset($options[$vocabulary->name]);
      }
      if (i18n_taxonomy_vocabulary_mode($vid) & I18N_MODE_LOCALIZE) {
        $tree = taxonomy_get_tree($vid);
        if ($tree && count($tree) > 0) {
          foreach ($tree as $term) {
            if (isset($options[$vname][$term->tid])) {
              $options[$vname][$term->tid] = str_repeat('-', $term->depth) . i18n_taxonomy_term_name($term);
            }
          }
        }
      }
    }
  }
}