Skip to content

Commit

Permalink
Lang Fallback (#36044)
Browse files Browse the repository at this point in the history
* let lang be found in base directory

* allow method to override lang path
  • Loading branch information
taylorotwell authored Jan 25, 2021
1 parent 1f8d0f3 commit e93c478
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ class Application extends Container implements ApplicationContract, CachesConfig
*/
protected $databasePath;

/**
* The custom language file path defined by the developer.
*
* @var string
*/
protected $langPath;

/**
* The custom storage path defined by the developer.
*
Expand Down Expand Up @@ -407,7 +414,30 @@ public function useDatabasePath($path)
*/
public function langPath()
{
return $this->resourcePath().DIRECTORY_SEPARATOR.'lang';
if ($this->langPath) {
return $this->langPath;
}

if (is_dir($path = $this->resourcePath().DIRECTORY_SEPARATOR.'lang')) {
return $path;
}

return $this->basePath().DIRECTORY_SEPARATOR.'lang';
}

/**
* Set the language file directory.
*
* @param string $path
* @return $this
*/
public function useLangPath($path)
{
$this->langPath = $path;

$this->instance('path.lang', $path);

return $this;
}

/**
Expand Down

0 comments on commit e93c478

Please sign in to comment.