function _potx_process_file in Translation template extractor 8
Same name and namespace in other branches
- 5.2 potx.inc \_potx_process_file()
- 5 potx.inc \_potx_process_file()
- 6.3 potx.inc \_potx_process_file()
- 6 potx.inc \_potx_process_file()
- 6.2 potx.inc \_potx_process_file()
- 7.3 potx.inc \_potx_process_file()
- 7 potx.inc \_potx_process_file()
- 7.2 potx.inc \_potx_process_file()
Process a file and put extracted information to the given parameters.
Parameters
string $file_path: Complete path to file to process.
string $strip_prefix: An integer denoting the number of chars to strip from filepath for output.
string $save_callback: Callback function to use to save the collected strings.
string $version_callback: Callback function to use to save collected version numbers.
int $api_version: Drupal API version to work with.
5 calls to _potx_process_file()
- PotxCommands::potx in src/
Commands/ PotxCommands.php - Extract translatable strings from Drupal source code.
- PotxExtractTranslationForm::submitForm in src/
Form/ PotxExtractTranslationForm.php - Form submission handler.
- PotxTest::parseFile in tests/
src/ Kernel/ PotxTest.php - Parse the given file with the given API version.
- PotxTest::testDrupal8ShippedConfiguration in tests/
src/ Kernel/ PotxTest.php - Test parsing of Drupal 8 shipped configuration files.
- potx_drush_extract in ./
potx.drush.inc - Drush command callback.
File
- ./
potx.inc, line 183 - Extraction API used by the web and command line interface.
Code
function _potx_process_file($file_path, $strip_prefix = 0, $save_callback = '_potx_save_string', $version_callback = '_potx_save_version', $api_version = POTX_API_CURRENT) {
// Figure out the basename and extension to select extraction method.
$basename = basename($file_path);
$name_parts = pathinfo($basename);
// Always grab the CVS version number from the code.
$code = file_get_contents($file_path);
$file_name = $strip_prefix > 0 ? substr($file_path, $strip_prefix) : $file_path;
_potx_find_version_number($code, $file_name, $version_callback);
// The .info files are not PHP code, no need to tokenize.
if ($name_parts['extension'] == 'info' && $api_version < POTX_API_8) {
_potx_find_info_file_strings($file_path, $file_name, $save_callback, $api_version);
return;
}
elseif ($name_parts['extension'] == 'yml' && $api_version > POTX_API_7) {
_potx_parse_yaml_file($code, $file_name, $file_path, $save_callback);
}
elseif ($name_parts['extension'] == 'js' && $api_version > POTX_API_5) {
// @todo: D7 context support.
_potx_parse_js_file($code, $file_name, $save_callback);
}
elseif ($name_parts['extension'] == 'twig' && $api_version > POTX_API_7) {
_potx_parse_twig_file($code, $file_name, $save_callback);
}
_potx_parse_php_file($code, $file_name, $save_callback, $name_parts, $basename, $api_version);
}