You are here

function _potx_parse_yaml_file in Translation template extractor 7.2

Same name and namespace in other branches
  1. 8 potx.inc \_potx_parse_yaml_file()
  2. 6.3 potx.inc \_potx_parse_yaml_file()
  3. 7.3 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 1953
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 (!isset($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)) {
      $yaml = Yaml::parse($code);
      _potx_find_yaml_translatables($yaml, $trans_list, $file_name, $save_callback);
    }
  }
  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/[^/]+\\.yml$~', $file_name)) {
    $_potx_config_set[] = $file_path;
  }
}