Skip to content

Commit

Permalink
Support new installers location. Avoid infinite loop in translator. Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm authored and enzolutions committed Aug 20, 2019
1 parent 5134178 commit cf7a95f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Utils/DrupalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ protected function defineConstants($vendorDir)
"/{$vendorDir}/drupal/console-%s/translations/"
);
}
if (!defined("DRUPAL_CONSOLE_LANGUAGE_INSTALLERS")) {
define(
"DRUPAL_CONSOLE_LANGUAGE_INSTALLERS",
"/console/language/console-%s/translations/"
);
}

if (!defined("DRUPAL_CONSOLE_LIBRARY")) {
define(
Expand Down
20 changes: 18 additions & 2 deletions src/Utils/TranslatorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,32 @@ private function buildCoreLanguageDirectory(
DRUPAL_CONSOLE_LANGUAGE,
$language
);
$installersLanguageDirectory =
$directoryRoot .
sprintf(
DRUPAL_CONSOLE_LANGUAGE_INSTALLERS,
$language
);

$languageDirectory = null;
foreach ([$coreLanguageDirectory, $installersLanguageDirectory] as $candidate) {
if (is_dir($candidate)) {
$languageDirectory = $candidate;
}
}

if (!is_dir($coreLanguageDirectory)) {
if (!isset($languageDirectory)) {
if ($language == 'en') {
throw new \Exception('No languages found. Make sure you have installed a console language package in a supported directory');
}
return $this->buildCoreLanguageDirectory('en', $directoryRoot);
}

if (!$this->coreLanguageRoot) {
$this->coreLanguageRoot = $directoryRoot;
}

return [$language, $coreLanguageDirectory];
return [$language, $languageDirectory];
}

/**
Expand Down

0 comments on commit cf7a95f

Please sign in to comment.