mirror of
https://github.com/archtechx/gloss.git
synced 2025-12-12 11:14:04 +00:00
support closures inside arrays
This commit is contained in:
parent
d40e868b13
commit
7c509ed137
1 changed files with 16 additions and 9 deletions
|
|
@ -229,20 +229,27 @@ class GlossTranslator extends Translator
|
|||
if (is_string($line) || is_callable($line)) { // Changed
|
||||
return $this->makeReplacements($line, $replace);
|
||||
} elseif (is_array($line) && count($line) > 0) {
|
||||
foreach ($line as $key => $value) {
|
||||
if (! is_callable($value)) {
|
||||
$value = $this->makeReplacements($value, $replace);
|
||||
}
|
||||
|
||||
$line[$key] = $value;
|
||||
}
|
||||
|
||||
return $line;
|
||||
return $this->makeReplacementsInArray($line, $replace);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function makeReplacementsInArray(array $lines, array $replace): array
|
||||
{
|
||||
foreach ($lines as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$value = $this->makeReplacementsInArray($value, $replace);
|
||||
} else {
|
||||
$value = $this->makeReplacements($value, $replace);
|
||||
}
|
||||
|
||||
$lines[$key] = $value;
|
||||
}
|
||||
|
||||
return $lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|callable $line
|
||||
* @param array $replace
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue