You are here

function tmgmt_local_supported_language_pairs in Translation Management Tool 8

Same name and namespace in other branches
  1. 7 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()
LocalTranslatorTest::testAbilitiesAPI in translators/tmgmt_local/tests/src/Functional/LocalTranslatorTest.php
TaskEligible::query in translators/tmgmt_local/src/Plugin/views/filter/TaskEligible.php
Add this filter to the query.
tmgmt_local_supported_target_languages in translators/tmgmt_local/tmgmt_local.module
Gets supported target languages.

File

translators/tmgmt_local/tmgmt_local.module, line 507
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_abilities($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];
}