package and depencies
This commit is contained in:
@@ -57,10 +57,8 @@ class PoFileLoader extends FileLoader
|
||||
* - Message IDs are allowed to have other encodings as just US-ASCII.
|
||||
*
|
||||
* Items with an empty id are ignored.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function loadResource(string $resource)
|
||||
protected function loadResource(string $resource): array
|
||||
{
|
||||
$stream = fopen($resource, 'r');
|
||||
|
||||
@@ -83,15 +81,15 @@ class PoFileLoader extends FileLoader
|
||||
}
|
||||
$item = $defaults;
|
||||
$flags = [];
|
||||
} elseif ('#,' === substr($line, 0, 2)) {
|
||||
} elseif (str_starts_with($line, '#,')) {
|
||||
$flags = array_map('trim', explode(',', substr($line, 2)));
|
||||
} elseif ('msgid "' === substr($line, 0, 7)) {
|
||||
} elseif (str_starts_with($line, 'msgid "')) {
|
||||
// We start a new msg so save previous
|
||||
// TODO: this fails when comments or contexts are added
|
||||
$this->addMessage($messages, $item);
|
||||
$item = $defaults;
|
||||
$item['ids']['singular'] = substr($line, 7, -1);
|
||||
} elseif ('msgstr "' === substr($line, 0, 8)) {
|
||||
} elseif (str_starts_with($line, 'msgstr "')) {
|
||||
$item['translated'] = substr($line, 8, -1);
|
||||
} elseif ('"' === $line[0]) {
|
||||
$continues = isset($item['translated']) ? 'translated' : 'ids';
|
||||
@@ -102,9 +100,9 @@ class PoFileLoader extends FileLoader
|
||||
} else {
|
||||
$item[$continues] .= substr($line, 1, -1);
|
||||
}
|
||||
} elseif ('msgid_plural "' === substr($line, 0, 14)) {
|
||||
} elseif (str_starts_with($line, 'msgid_plural "')) {
|
||||
$item['ids']['plural'] = substr($line, 14, -1);
|
||||
} elseif ('msgstr[' === substr($line, 0, 7)) {
|
||||
} elseif (str_starts_with($line, 'msgstr[')) {
|
||||
$size = strpos($line, ']');
|
||||
$item['translated'][(int) substr($line, 7, 1)] = substr($line, $size + 3, -1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user