Skip to content

Commit

Permalink
Merge 913fc96 into 75e9eeb
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleylancel committed May 6, 2020
2 parents 75e9eeb + 913fc96 commit ba77074
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Kunstmaan/TranslatorBundle/Service/TranslationFileExplorer.php
Expand Up @@ -4,16 +4,10 @@

use Kunstmaan\TranslatorBundle\Service\Exception\TranslationsNotFoundException;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\Kernel;

class TranslationFileExplorer
{
/**
* Symfony default translation folder (in a bundle)
*
* @var string
*/
private $defaultTranslationFolder = 'Resources/translations';

/**
* An array of supported file formats to look for
*
Expand All @@ -32,7 +26,7 @@ class TranslationFileExplorer
public function find($path, array $locales, $translationDirectory = null)
{
$finder = new Finder();
$translationDirectory = $translationDirectory ?? $this->defaultTranslationFolder;
$translationDirectory = $translationDirectory ?? $this->getDefaultTranslationFolder();

$exploreDir = $path . '/' . $translationDirectory;

Expand All @@ -51,4 +45,13 @@ public function setFileFormats($fileFormats)
{
$this->fileFormats = $fileFormats;
}

protected function getDefaultTranslationFolder(): string
{
if (Kernel::VERSION_ID >= 40000) {
return 'translations';
}

return 'Resources/translations';
}
}

0 comments on commit ba77074

Please sign in to comment.