You are here

function _potx_find_info_file_strings in Translation template extractor 8

Same name and namespace in other branches
  1. 5.2 potx.inc \_potx_find_info_file_strings()
  2. 5 potx.inc \_potx_find_info_file_strings()
  3. 6.3 potx.inc \_potx_find_info_file_strings()
  4. 6 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

string $file_path: Complete file path to load contents with.

string $file_name: Stripped file name to use in outpout.

string $save_callback: Callback function used to save strings.

int $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 1814
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 = [];
  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 ([
    '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);
    }
  }
}