![]() Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : fdshops ( 1003) PHP Version : 8.2.21 Disable Function : NONE Directory : /home/fdshops/public_html/vendor/knuckleswtf/scribe/src/Writing/ |
<?php namespace Knuckles\Scribe\Writing; use Illuminate\Translation\FileLoader; use Knuckles\Scribe\Tools\Globals; use Illuminate\Contracts\Translation\Loader as LoaderContract; class CustomTranslationsLoader extends FileLoader { protected LoaderContract $defaultLoader; protected mixed $langPath; protected ?array $scribeTranslationsCache = null; protected ?array $userTranslationsCache = null; public function __construct(LoaderContract $loader) { $this->defaultLoader = $loader; $this->files = app('files'); $this->langPath = app('path.lang'); } public function load($locale, $group, $namespace = null) { // Laravel expects translation strings to be broken up into groups (files): // `lang/scribe/en/auth.php`, `lang/scribe/en/links.php` // We want to trick it into accepting a simple `lang/scribe.php`. if ($namespace == 'scribe') { if (isset($this->scribeTranslationsCache)) { $lines = $this->scribeTranslationsCache[$group] ?? []; } elseif ($this->files->exists($full = "{$this->hints[$namespace]}/scribe.php")) { $this->scribeTranslationsCache = $this->files->getRequire($full); $lines = $this->scribeTranslationsCache[$group] ?? []; } else { return []; } return $this->loadScribeNamespaceOverrides($lines, $locale, $group, $namespace); } return $this->defaultLoader->load($locale, $group, $namespace); } protected function loadScribeNamespaceOverrides(array $lines, $locale, $group, $namespace) { $userTranslationsFile = "{$this->langPath}/scribe.php"; if ($this->files->exists($userTranslationsFile)) { if (!isset($this->userTranslationsCache)) { $this->userTranslationsCache = $this->files->getRequire($userTranslationsFile); } $userTranslations = $this->userTranslationsCache[$group] ?? []; return array_replace_recursive($lines, $userTranslations); } return $lines; } }