You are here

function _potx_find_info_file_strings in Translation template extractor 7.2

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 potx.inc \_potx_find_info_file_strings()
  6. 6.2 potx.inc \_potx_find_info_file_strings()
  7. 7.3 potx.inc \_potx_find_info_file_strings()
  8. 7 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 1533
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_CURRENT) {
  $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])) {

      // No context support for .info file strings.
      $save_callback(addcslashes($info[$key], "\0..\37\\\""), POTX_CONTEXT_NONE, $file_name);
    }
  }

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

      // No context support for .info file strings.
      $save_callback(addcslashes($region_name, "\0..\37\\\""), POTX_CONTEXT_NONE, $file_name);
    }
  }
}