X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/934a833818b77e51f83d21a22478aea36ae9a294..refs/pull/5721/head:/app/Translation/FileLoader.php diff --git a/app/Translation/FileLoader.php b/app/Translation/FileLoader.php index 1ed7b06cc..1fec4d18b 100644 --- a/app/Translation/FileLoader.php +++ b/app/Translation/FileLoader.php @@ -8,24 +8,31 @@ class FileLoader extends BaseLoader { /** * Load the messages for the given locale. + * * Extends Laravel's translation FileLoader to look in multiple directories * so that we can load in translation overrides from the theme file if wanted. * + * Note: As of using Laravel 10, this may now be redundant since Laravel's + * file loader supports multiple paths. This needs further testing though + * to confirm if Laravel works how we expect, since we specifically need + * the theme folder to be able to partially override core lang files. + * * @param string $locale * @param string $group * @param string|null $namespace * * @return array */ - public function load($locale, $group, $namespace = null) + public function load($locale, $group, $namespace = null): array { if ($group === '*' && $namespace === '*') { return $this->loadJsonPaths($locale); } if (is_null($namespace) || $namespace === '*') { - $themeTranslations = $this->loadPath(theme_path('lang'), $locale, $group); - $originalTranslations = $this->loadPath($this->path, $locale, $group); + $themePath = theme_path('lang'); + $themeTranslations = $themePath ? $this->loadPaths([$themePath], $locale, $group) : []; + $originalTranslations = $this->loadPaths($this->paths, $locale, $group); return array_merge($originalTranslations, $themeTranslations); }