<?php namespace BW\TranslationOverrider;

use Illuminate\Translation\FileLoader as IlluminateFileLoader;

class FileLoader extends IlluminateFileLoader
{

    /**
     * Load a locale from a given path.
     *
     * @param  string  $path
     * @param  string  $locale
     * @param  string  $group
     * @return array
     */
    protected function loadPath($path, $locale, $group)
    {
        $return = [];

        if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
            $return = array_replace_recursive($return, $this->files->getRequire($full));
        }

        if ($this->files->exists($full = "{$path}/overrides/{$locale}/{$group}.php")) {
            $return = array_replace_recursive($return, $this->files->getRequire($full));
        }

        return $return;
    }
}
