Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Language strings from other locations #1488

Merged
merged 2 commits into from
Nov 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions system/Language/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ protected function load(string $file, string $locale, bool $return = false)
* A simple method for including files that can be
* overridden during testing.
*
* @todo - should look into loading from other locations, also probably...
*
* @param string $path
*
* @return array
Expand All @@ -259,6 +257,8 @@ protected function requireFile(string $path): array
{
$files = service('locator')->search($path);

$strings = [];

foreach ($files as $file)
{
if (! is_file($file))
Expand All @@ -270,10 +270,19 @@ protected function requireFile(string $path): array
// on this command returning boolean instead
// of array during testing, so we've removed
// the require_once for now.
return require $file;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No performance issues here. $files comes with only the matching files.

$strings[] = require $file;
}

if (isset($strings[1]))
{
$strings = array_replace_recursive(...$strings);
}
elseif (isset($strings[0]))
{
$strings = $strings[0];
}

return [];
return $strings;
}

//--------------------------------------------------------------------
Expand Down