You are here

private function PoStreamReader::fetchGroupFromComment in Localization update 7.2

Determine a translation text group using a source's comment-string.

Parameters

string $comment: Comment string.

Return value

string The comment's text group.

1 call to PoStreamReader::fetchGroupFromComment()
PoStreamReader::setItemFromArray in includes/gettext/PoStreamReader.php
Store the parsed values as a PoItem object.

File

includes/gettext/PoStreamReader.php, line 612
Contains \Drupal\Component\Gettext\PoStreamReader.

Class

PoStreamReader
Implements Gettext PO stream reader.

Code

private function fetchGroupFromComment($comment) {

  // Only if i18n_string is installed, check for and set textgroups.
  if (module_exists('i18n_string') && strpos($comment, ':') !== FALSE) {

    // Fetch available textgroups.
    $groups = array_keys(i18n_string_group_info());

    // Parse textgroup from comment (assume default drupal exports).
    $comment_array = explode(':', $comment);
    if (!empty($comment_array) && in_array($comment_array[0], $groups)) {
      return $comment_array[0];
    }
  }
  return 'default';
}