You are here

function _potx_find_info_file_strings in Translation template extractor 6

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

Parse an .info file and add relevant strings to the list.

Parameters

$file_path: Complete file path to load contents with.

$file_name: Stripped file name to use in outpout.

$strings: Current strings array

$api_version: Drupal API version to work with.

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

File

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

Code

function _potx_find_info_file_strings($file_path, $file_name, $save_callback, $api_version = POTX_API_6) {
  $info = array();
  if (file_exists($file_path)) {
    $info = $api_version > POTX_API_5 ? drupal_parse_info_file($file_path) : parse_ini_file($file_path);
  }

  // We need the name, description and package values. Others,
  // like core and PHP compatibility, timestamps or versions
  // are not to be translated.
  foreach (array(
    'name',
    'description',
    'package',
  ) as $key) {
    if (isset($info[$key])) {
      $save_callback($info[$key], $file_name);
    }
  }

  // Add regions names from themes.
  if (isset($info['regions']) && is_array($info['regions'])) {
    foreach ($info['regions'] as $region => $region_name) {
      $save_callback($region_name, $file_name);
    }
  }
}