Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Simplify. #14
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Feb 14, 2017
1 parent 4e370df commit e8ec3e6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,22 @@ public function load($locale, $group, $namespace = null)

return array_replace_recursive($defaults, parent::load($locale, $group, $namespace));
}
/**

/**
* Fall back to base locale (i.e. de) if a countries specific locale (i.e. de-CH) is not available
*
* @param string $path
* @param string $locale
* @param string $group
* @return array|mixed
*
* @return array
*/
protected function loadPath($path, $locale, $group)
{
$result = parent::loadPath($path, $locale, $group);

if ($result == [] && strpos($locale, '-') !== false) {
list($baseLocale) = explode('-', $locale);
if ($this->files->exists($full = "{$path}/{$baseLocale}/{$group}.php")) {
return $this->files->getRequire($full);
}
if (empty($result) && str_contains($locale, '-')) {
return parent::loadPath($path, strstr($locale, '-', true), $group);
}

return $result;
Expand Down

0 comments on commit e8ec3e6

Please sign in to comment.