mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 16:51:02 +08:00
Allows configuration of where the language files live. So that
language packs can optionally decide for themselves if they want to use a different directory.
This commit is contained in:
parent
720c88e73a
commit
9209a5f588
|
@ -20,6 +20,18 @@ use RuntimeException;
|
||||||
|
|
||||||
class LanguagePack implements ExtenderInterface, LifecycleInterface
|
class LanguagePack implements ExtenderInterface, LifecycleInterface
|
||||||
{
|
{
|
||||||
|
protected $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LanguagePack constructor.
|
||||||
|
*
|
||||||
|
* @param string|null $path Path to yaml language files.
|
||||||
|
*/
|
||||||
|
public function __construct(string $path = null)
|
||||||
|
{
|
||||||
|
$this->path = $path;
|
||||||
|
}
|
||||||
|
|
||||||
public function extend(Container $container, Extension $extension = null)
|
public function extend(Container $container, Extension $extension = null)
|
||||||
{
|
{
|
||||||
if (is_null($extension)) {
|
if (is_null($extension)) {
|
||||||
|
@ -49,7 +61,7 @@ class LanguagePack implements ExtenderInterface, LifecycleInterface
|
||||||
{
|
{
|
||||||
$locales->addLocale($locale, $title);
|
$locales->addLocale($locale, $title);
|
||||||
|
|
||||||
$directory = $extension->getPath().'/locale';
|
$directory = $extension->getPath().($this->path ?? '/locale');
|
||||||
|
|
||||||
if (! is_dir($directory)) {
|
if (! is_dir($directory)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user