Customise the translation loader to find translations by group

parent 7adf7392
......@@ -2,7 +2,10 @@
namespace Modules\Translation\Services;
class TranslationLoader extends \Illuminate\Translation\FileLoader
use Illuminate\Translation\FileLoader;
use Modules\Translation\Repositories\TranslationRepository;
class TranslationLoader extends FileLoader
{
/**
* Get all Paths where Translations could be found.
......@@ -15,4 +18,22 @@ class TranslationLoader extends \Illuminate\Translation\FileLoader
$this->hints
);
}
/**
* Load the messages for the given locale.
*
* @param string $locale
* @param string $group
* @param string $namespace
*
* @return array
*/
public function load($locale, $group, $namespace = null): array
{
$fileTranslations = parent::load($locale, $group, $namespace);
$loaderTranslations = app(TranslationRepository::class)->getTranslationsForGroupAndNamespace($locale, $group, $namespace);
return array_merge($fileTranslations, $loaderTranslations);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment