You are here

function _potx_find_language_names in Translation template extractor 7.2

Same name and namespace in other branches
  1. 8 potx.inc \_potx_find_language_names()
  2. 5.2 potx.inc \_potx_find_language_names()
  3. 5 potx.inc \_potx_find_language_names()
  4. 6.3 potx.inc \_potx_find_language_names()
  5. 6 potx.inc \_potx_find_language_names()
  6. 6.2 potx.inc \_potx_find_language_names()
  7. 7.3 potx.inc \_potx_find_language_names()
  8. 7 potx.inc \_potx_find_language_names()

Get languages names from Drupal's locale.inc.

Parameters

$file: Full path name of file parsed

$save_callback: Callback function used to save strings.

$api_version: Drupal API version to work with.

1 call to _potx_find_language_names()
_potx_process_file in ./potx.inc
Process a file and put extracted information to the given parameters.

File

./potx.inc, line 1360
Extraction API used by the web and command line interface.

Code

function _potx_find_language_names($file, $save_callback, $api_version = POTX_API_CURRENT) {
  global $_potx_tokens, $_potx_lookup;
  if ($api_version > POTX_API_7) {
    $key = 'getStandardLanguageList';
  }
  elseif ($api_version > POTX_API_5) {
    $key = '_locale_get_predefined_list';
  }
  else {
    $key = '_locale_get_iso639_list';
  }
  foreach ($_potx_lookup[$key] as $ti) {

    // Search for the definition of _locale_get_predefined_list(), not where it is called.
    if ($_potx_tokens[$ti - 1][0] == T_FUNCTION) {
      break;
    }
  }
  $end = _potx_find_end_of_function($ti);
  $ti += 7;

  // function name, (, ), {, return, array, (
  while ($ti < $end) {
    while ($_potx_tokens[$ti][0] != T_ARRAY) {
      if (!is_array($_potx_tokens[$ti]) && $_potx_tokens[$ti] == ';') {

        // We passed the end of the list, break out to function level
        // to prevent an infinite loop.
        break 2;
      }
      $ti++;
    }
    $ti += 2;

    // array, (
    // Language names are context-less.
    $save_callback(_potx_format_quoted_string($_potx_tokens[$ti][1]), POTX_CONTEXT_NONE, $file, $_potx_tokens[$ti][2]);
  }
}