Skip to content

Commit e93c478

Browse files
authored
Lang Fallback (#36044)
* let lang be found in base directory * allow method to override lang path
1 parent 1f8d0f3 commit e93c478

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/Illuminate/Foundation/Application.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ class Application extends Container implements ApplicationContract, CachesConfig
112112
*/
113113
protected $databasePath;
114114

115+
/**
116+
* The custom language file path defined by the developer.
117+
*
118+
* @var string
119+
*/
120+
protected $langPath;
121+
115122
/**
116123
* The custom storage path defined by the developer.
117124
*
@@ -407,7 +414,30 @@ public function useDatabasePath($path)
407414
*/
408415
public function langPath()
409416
{
410-
return $this->resourcePath().DIRECTORY_SEPARATOR.'lang';
417+
if ($this->langPath) {
418+
return $this->langPath;
419+
}
420+
421+
if (is_dir($path = $this->resourcePath().DIRECTORY_SEPARATOR.'lang')) {
422+
return $path;
423+
}
424+
425+
return $this->basePath().DIRECTORY_SEPARATOR.'lang';
426+
}
427+
428+
/**
429+
* Set the language file directory.
430+
*
431+
* @param string $path
432+
* @return $this
433+
*/
434+
public function useLangPath($path)
435+
{
436+
$this->langPath = $path;
437+
438+
$this->instance('path.lang', $path);
439+
440+
return $this;
411441
}
412442

413443
/**

0 commit comments

Comments
 (0)