You are here

protected function LingotekInterfaceTranslationService::extractPotxStrings in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.2.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::extractPotxStrings()
  2. 3.3.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::extractPotxStrings()
  3. 3.4.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::extractPotxStrings()
  4. 3.5.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::extractPotxStrings()
  5. 3.6.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::extractPotxStrings()
  6. 3.7.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::extractPotxStrings()
  7. 3.8.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::extractPotxStrings()

Extract strings by using potx module.

Parameters

string $component: The component we want to extract the strings from.

Return value

array Collection of strings in the potx format: string => [ context => context_info, context => context_info, ]

1 call to LingotekInterfaceTranslationService::extractPotxStrings()
LingotekInterfaceTranslationService::getSourceData in src/LingotekInterfaceTranslationService.php
Returns the source data that will be uploaded to the Lingotek service.

File

src/LingotekInterfaceTranslationService.php, line 1111

Class

LingotekInterfaceTranslationService
Service for managing Lingotek interface translations.

Namespace

Drupal\lingotek

Code

protected function extractPotxStrings($component) {
  global $_potx_strings;
  $this->moduleHandler
    ->loadInclude('potx', 'inc');
  $this->moduleHandler
    ->loadInclude('potx', 'inc', 'potx.local');

  // Silence status messages.
  potx_status('set', POTX_STATUS_MESSAGE);
  $pathinfo = pathinfo($component);
  if (!isset($pathinfo['filename'])) {

    // The filename key is only available in PHP 5.2.0+.
    $pathinfo['filename'] = substr($pathinfo['basename'], 0, strrpos($pathinfo['basename'], '.'));
  }
  if (isset($pathinfo['extension'])) {

    // A specific module or theme file was requested (otherwise there should
    // be no extension).
    potx_local_init($pathinfo['dirname']);
    $files = _potx_explore_dir($pathinfo['dirname'] . '/', $pathinfo['filename']);
    $strip_prefix = 1 + strlen($pathinfo['dirname']);
  }
  else {
    potx_local_init($component);
    $files = _potx_explore_dir($component . '/');
    $strip_prefix = 1 + strlen($component);
  }

  // Collect every string in affected files. Installer related strings are
  // discarded.
  foreach ($files as $file) {
    _potx_process_file($file, $strip_prefix);
  }
  potx_finish_processing('_potx_save_string');
  return $_potx_strings;
}