You are here

function i18ntaxonomy_form_all_localize in Internationalization 6

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 i18ntaxonomy_form_all_localize()
i18ntaxonomy_form_alter in i18ntaxonomy/i18ntaxonomy.module
Implementation of hook_form_alter().

File

i18ntaxonomy/i18ntaxonomy.module, line 503
i18n taxonomy module

Code

function i18ntaxonomy_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 = i18ntaxonomy_translate_vocabulary_name($vocabulary->name);
      if ($vname != $vocabulary->name) {
        $options[$vname] = $options[$vocabulary->name];
        unset($options[$vocabulary->name]);
      }
      if (i18ntaxonomy_vocabulary($vid) == I18N_TAXONOMY_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) . i18ntaxonomy_translate_term_name($term->tid, $term->name);
            }
          }
        }
      }
    }
  }
}