Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Commit

Permalink
Merge pull request #65 from KasperFranz/feature/better-exceptions
Browse files Browse the repository at this point in the history
Better Exception handling
  • Loading branch information
shaggyz committed Mar 10, 2016
2 parents 859a7f9 + 707e80d commit 53b9062
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/Xinax/LaravelGettext/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public function compileViews(array $viewPaths, $domain)
foreach ($viewPaths as $path) {
$path = $this->basePath . DIRECTORY_SEPARATOR . $path;

if (empty(realpath($path))) {
throw new Exceptions\DirectoryNotFoundException(sprintf(
'The source-path: %s, is not found, please check that it exists, and update your config with the right path.',
$path
));
}

$fs = new \Illuminate\Filesystem\Filesystem($path);
$files = $fs->allFiles(realpath($path));

Expand Down Expand Up @@ -231,19 +238,26 @@ public function addLocale($localePath, $locale)
"LC_MESSAGES"
);

$this->createDirectory($localePath);
if (!file_exists($localePath)) {
$this->createDirectory($localePath);
}

if ( $this->configuration->getCustomLocale() ) {
$data[1] = 'C';

$gettextPath = implode($data, DIRECTORY_SEPARATOR);
$this->createDirectory($gettextPath);
if (!file_exists($gettextPath)) {
$this->createDirectory($gettextPath);
}

$data[2] = 'LC_MESSAGES';
}

$gettextPath = implode($data, DIRECTORY_SEPARATOR);
$this->createDirectory($gettextPath);
if (!file_exists($gettextPath)) {
$this->createDirectory($gettextPath);
}


// File generation for each domain
foreach ($this->configuration->getAllDomains() as $domain) {
Expand Down Expand Up @@ -427,8 +441,9 @@ public function checkDirectoryStructure($checkLocales = false)
public function generateLocales()
{
// Application base path
$this->createDirectory($this->getDomainPath());

if (!file_exists($this->getDomainPath())) {
$this->createDirectory($this->getDomainPath());
}
$localePaths = [];

// Locale directories
Expand Down

0 comments on commit 53b9062

Please sign in to comment.