<?php

namespace App\Supports;

use Illuminate\Translation\FileLoader;
use App\Language;

class TranslationLoader extends FileLoader
{
    public function load($locale, $group, $namespace = null)
    {
        $fileTranslations = parent::load($locale, $group, $namespace);

        if (! is_null($namespace) && $namespace !== '*') {
            return $fileTranslations;
        }

        $loaderTranslations = Language::getGroup($group, $locale);

        return array_replace_recursive($fileTranslations, $loaderTranslations);
    }
}
