Skip to content

Commit

Permalink
Add Language::findLines method
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Feb 13, 2022
1 parent b4d2152 commit 66c2f55
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,27 @@ protected function getLine(string $locale, string $file, string $line) : ?string
return null;
}
$this->addFindedLocale($locale);
$this->findLines($locale, $file);
return $this->languages[$locale][$file][$line] ?? null;
}

/**
* Find and add lines.
*
* This method can be overridden to find lines in custom storage, such as
* in a database table.
*
* @param string $locale
* @param string $file
*
* @return static
*/
protected function findLines(string $locale, string $file) : static
{
foreach ($this->findFilenames($locale, $file) as $filename) {
$this->addLines($locale, $file, $this->getFileLines($filename));
}
return $this->languages[$locale][$file][$line] ?? null;
return $this;
}

/**
Expand Down

0 comments on commit 66c2f55

Please sign in to comment.