3 namespace BookStack\Translation;
5 use Illuminate\Translation\FileLoader as BaseLoader;
7 class FileLoader extends BaseLoader
10 * Load the messages for the given locale.
12 * Extends Laravel's translation FileLoader to look in multiple directories
13 * so that we can load in translation overrides from the theme file if wanted.
15 * Note: As of using Laravel 10, this may now be redundant since Laravel's
16 * file loader supports multiple paths. This needs further testing though
17 * to confirm if Laravel works how we expect, since we specifically need
18 * the theme folder to be able to partially override core lang files.
20 * @param string $locale
21 * @param string $group
22 * @param string|null $namespace
26 public function load($locale, $group, $namespace = null): array
28 if ($group === '*' && $namespace === '*') {
29 return $this->loadJsonPaths($locale);
32 if (is_null($namespace) || $namespace === '*') {
33 $themePath = theme_path('lang');
34 $themeTranslations = $themePath ? $this->loadPaths([$themePath], $locale, $group) : [];
35 $originalTranslations = $this->loadPaths($this->paths, $locale, $group);
37 return array_merge($originalTranslations, $themeTranslations);
40 return $this->loadNamespaced($locale, $group, $namespace);