You are here

function i18n_node_language_list in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_node_language_list()
  2. 5 i18n.module \i18n_node_language_list()
  3. 5.2 i18n.module \i18n_node_language_list()
  4. 7 i18n_node/i18n_node.module \i18n_node_language_list()

Get allowed languages for node.

This allows node types to define its own language list implementing hook 'language_list'.

Parameters

$node: Node to retrieve language list for.

$translate: Only languages available for translation. Filter out existing translations.

1 call to i18n_node_language_list()
i18n_form_alter in ./i18n.module
Implementation of hook_form_alter();

File

./i18n.module, line 358
Internationalization (i18n) module.

Code

function i18n_node_language_list($node, $translate = FALSE) {

  // Check if the node module manages its own language list.
  $languages = node_invoke($node, 'language_list', $translate);
  if (!$languages) {
    if (variable_get('i18n_node_' . $node->type, 0) >= LANGUAGE_SUPPORT_EXTENDED) {
      $languages = locale_language_list('name', TRUE);

      // All defined languages
    }
    else {
      $languages = locale_language_list();

      // All enabled languages
    }
    if ($translate && isset($node->tnid) && $node->tnid && ($translations = translation_node_get_translations($node->tnid))) {
      unset($translations[$node->language]);
      foreach (array_keys($translations) as $langcode) {
        unset($languages[$langcode]);
      }
    }

    // Language may be locked for this node type, restrict options to current one
    if (variable_get('i18n_lock_node_' . $node->type, 0) && !empty($node->language) && !empty($languages[$node->language])) {
      $languages = array(
        $node->language => $languages[$node->language],
      );
    }
    elseif (!variable_get('i18n_required_node_' . $node->type, 0)) {
      $languages = array(
        '' => t('Language neutral'),
      ) + $languages;
    }
  }
  return $languages;
}