You are here

function i18ntaxonomy_localize_terms in Internationalization 6

Localize taxonomy terms for localizable vocabularies.

Parameters

$terms: Array of term objects.

$fields: Object properties to localize.

Return value

Array of terms with the right ones localized.

3 calls to i18ntaxonomy_localize_terms()
i18ntaxonomy_nodeapi in i18ntaxonomy/i18ntaxonomy.module
Implementation of hook_nodeapi().
i18ntaxonomy_term_page in i18ntaxonomy/i18ntaxonomy.pages.inc
Menu callback; displays all nodes associated with a term.
i18ntaxonomy_vocabulary_form in i18ntaxonomy/i18ntaxonomy.module
Generate a form element for selecting terms from a vocabulary. Translates all translatable strings.

File

i18ntaxonomy/i18ntaxonomy.module, line 836
i18n taxonomy module

Code

function i18ntaxonomy_localize_terms($terms, $fields = array(
  'name',
  'description',
)) {
  $localize = i18ntaxonomy_vocabulary(NULL, I18N_TAXONOMY_LOCALIZE);
  foreach ($terms as $index => $term) {
    if (in_array($term->vid, $localize)) {

      // Clone objects just in case one of them is saved later
      $terms[$index] = clone $term;
      foreach ($fields as $property) {
        $terms[$index]->{$property} = i18nstrings("taxonomy:term:{$term->tid}:{$property}", $term->{$property});
      }
    }
  }
  return $terms;
}