You are here

function _potx_init_yaml_translation_patterns in Translation template extractor 8

Same name and namespace in other branches
  1. 6.3 potx.inc \_potx_init_yaml_translation_patterns()
  2. 7.3 potx.inc \_potx_init_yaml_translation_patterns()
  3. 7.2 potx.inc \_potx_init_yaml_translation_patterns()

Initialize the list of translation patterns for YAML files.

The patterns are loaded from a file named "yaml_translation_patterns.yml" in potx's root. Contrib projects can also include their own "yaml_translation_patterns.yml" file in their root folder to specify translatable strings in their own custom yaml files.

Parameters

string $path: The path to look for a custom "yaml_translation_patterns.yml" file.

3 calls to _potx_init_yaml_translation_patterns()
PotxTest::testDrupal8CustomYml in tests/src/Kernel/PotxTest.php
Test parsing of custom yaml files.
_potx_explore_dir in ./potx.inc
Collect a list of file names relevant for extraction, starting from $path.
_potx_parse_yaml_file in ./potx.inc
Parse a YAML file for translatables. Drupal 8+.

File

./potx.inc, line 2266
Extraction API used by the web and command line interface.

Code

function _potx_init_yaml_translation_patterns($path = '') {
  global $_potx_yaml_translation_patterns;
  if (!is_array($_potx_yaml_translation_patterns)) {
    $_potx_yaml_translation_patterns = [];
    $default_patterns = __DIR__ . '/yaml_translation_patterns.yml';
    _potx_load_yaml_translation_patterns($default_patterns);
  }
  $custom_patterns = $path . '/yaml_translation_patterns.yml';
  if (!empty($path) && file_exists($custom_patterns)) {
    _potx_load_yaml_translation_patterns($custom_patterns);
  }
}