You are here

function tmgmt_local_supported_language_pairs in Translation Management Tool 7

Same name and namespace in other branches
  1. 8 translators/tmgmt_local/tmgmt_local.module \tmgmt_local_supported_language_pairs()

Gets list of language pairs.

Parameters

string $source_language: Source language code for which to limit the selection.

array $uids: List of user ids for whom to get the language pairs.

Return value

array List of language pairs where a pair is defined by associative array of source_language and target_language keys.

3 calls to tmgmt_local_supported_language_pairs()
TMGMTLocalTestCase::testCapabilitiesAPI in translators/tmgmt_local/tmgmt_local.test
tmgmt_local_supported_target_languages in translators/tmgmt_local/tmgmt_local.module
Gets supported target languages.
tmgmt_local_task_handler_filter_eligible::query in translators/tmgmt_local/views/handlers/tmgmt_local_task_handler_filter_eligible.inc
Add this filter to the query.

File

translators/tmgmt_local/tmgmt_local.module, line 716
Main module file for the local translation module.

Code

function tmgmt_local_supported_language_pairs($source_language = NULL, $uids = array()) {
  $language_pairs =& drupal_static(__FUNCTION__);
  $cache_key = $source_language . '_' . implode('_', $uids);
  if (isset($language_pairs[$cache_key])) {
    return $language_pairs[$cache_key];
  }
  $language_pairs[$cache_key] = array();
  foreach (tmgmt_local_capabilities($source_language, NULL, $uids) as $row) {

    // Prevent duplicates.
    $pair_key = $row->tmgmt_translation_skills_language_from . '__' . $row->tmgmt_translation_skills_language_to;
    $language_pairs[$cache_key][$pair_key] = array(
      'source_language' => $row->tmgmt_translation_skills_language_from,
      'target_language' => $row->tmgmt_translation_skills_language_to,
    );
  }
  return $language_pairs[$cache_key];
}