Skip to content

Commit

Permalink
adding translation by library methods to the console (#3376)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonfil1 authored and enzolutions committed Jul 3, 2017
1 parent bc4b3ce commit 3cbeed2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Utils/TranslatorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class TranslatorManager extends TranslatorManagerBase
{
protected $extensions = [];

/**
* @param $extensionPath
*/
Expand Down Expand Up @@ -73,12 +75,27 @@ private function addResourceTranslationsByTheme($theme)
);
}

/**
* @param $library
*/
private function addResourceTranslationsByLibrary($library)
{
$path = \Drupal::service('console.root') . '/vendor/drupal/' . $library;
$this->addResourceTranslationsByExtensionPath(
$path
);
}

/**
* @param $extension
* @param $type
*/
public function addResourceTranslationsByExtension($extension, $type)
{
if (array_search($extension, $this->extensions) !== false) {
return;
}
$this->extensions[] = $extension;
if ($type == 'module') {
$this->addResourceTranslationsByModule($extension);
return;
Expand All @@ -87,5 +104,9 @@ public function addResourceTranslationsByExtension($extension, $type)
$this->addResourceTranslationsByTheme($extension);
return;
}
if ($type == 'library') {
$this->addResourceTranslationsByLibrary($extension);
return;
}
}
}

0 comments on commit 3cbeed2

Please sign in to comment.