-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add str_before if not exists Doc blocks * Different database loaders to satisfy Laravel <= 5.4 * Check for value * Update language * Formatting * Update return type
- Loading branch information
Showing
7 changed files
with
128 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace JoeDixon\Translation; | ||
|
||
use Illuminate\Translation\LoaderInterface; | ||
use JoeDixon\Translation\Drivers\Translation; | ||
|
||
class InterfaceDatabaseLoader implements LoaderInterface | ||
{ | ||
private $translation; | ||
|
||
public function __construct(Translation $translation) | ||
{ | ||
$this->translation = $translation; | ||
} | ||
|
||
/** | ||
* 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) | ||
{ | ||
if ($group == '*' && $namespace == '*') { | ||
return $this->translation->getSingleTranslationsFor($locale)->toArray(); | ||
} | ||
|
||
if (is_null($namespace) || $namespace == '*') { | ||
return $this->translation->getGroupTranslationsFor($locale)->filter(function ($value, $key) use ($group) { | ||
return $key === $group; | ||
})->first(); | ||
} | ||
|
||
return $this->translation->getGroupTranslationsFor($locale)->filter(function ($value, $key) use ($group, $namespace) { | ||
return $key === "{$namespace}::{$group}"; | ||
})->first(); | ||
} | ||
|
||
/** | ||
* Add a new namespace to the loader. | ||
* | ||
* @param string $namespace | ||
* @param string $hint | ||
* @return void | ||
*/ | ||
public function addNamespace($namespace, $hint) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Add a new JSON path to the loader. | ||
* | ||
* @param string $path | ||
* @return void | ||
*/ | ||
public function addJsonPath($path) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get an array of all the registered namespaces. | ||
* | ||
* @return array | ||
*/ | ||
public function namespaces() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters