function _potx_parse_yaml_file in Translation template extractor 6.3
Same name and namespace in other branches
- 8 potx.inc \_potx_parse_yaml_file()
- 7.3 potx.inc \_potx_parse_yaml_file()
- 7.2 potx.inc \_potx_parse_yaml_file()
Parse a YAML file for translatables. Drupal 8+.
1 call to _potx_parse_yaml_file()
- _potx_process_file in ./
potx.inc - Process a file and put extracted information to the given parameters.
File
- ./
potx.inc, line 2005 - Extraction API used by the web and command line interface.
Code
function _potx_parse_yaml_file($code, $file_name, $file_path, $save_callback) {
global $yaml_translation_patterns;
global $_potx_config_set;
if (!is_array($yaml_translation_patterns)) {
_potx_init_yaml_translation_patterns();
}
foreach ($yaml_translation_patterns as $pattern => $trans_list) {
if (fnmatch($pattern, $file_name) || fnmatch('*/' . $pattern, $file_name)) {
try {
$yaml = Yaml::parse($code);
_potx_find_yaml_translatables($yaml, $trans_list, $file_name, $save_callback);
} catch (ParseException $e) {
watchdog('potx', "YAML parseing error on file @path: @error", array(
'@path' => $file_path,
'@error' => $e
->getMessage(),
));
}
}
}
if (preg_match('~config/schema/[^/]+\\.yml$~', $file_name)) {
$schema = Yaml::parse($code);
foreach ($schema as $key => $element) {
_potx_process_config_schema($key, $element);
}
}
elseif (preg_match('~config/(install|optional)/[^/]+\\.yml$~', $file_name)) {
$_potx_config_set[] = $file_path;
}
}