Skip to content

Commit faeef90

Browse files
committed
#282 Renamed identifiers
1 parent 8439ddb commit faeef90

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/Loader/StrictPoLoader.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public function loadString(string $string, Translations $translations = null): T
3434
for ($this->newEntry(); $this->getChar() !== null; $this->newEntry()) {
3535
while ($this->readComment());
3636
$this->readContext();
37-
$this->readId();
38-
if ($this->readPlural()) {
39-
for ($isRequired = true; $this->readPluralTranslation($isRequired); $isRequired = false);
37+
$this->readOriginal();
38+
if ($this->readPlural() && $this->readPluralTranslation(true)) {
39+
while ($this->readPluralTranslation());
4040
} else {
4141
$this->readTranslation();
4242
}
@@ -106,9 +106,7 @@ private function readString(string $word): bool
106106
*/
107107
private function readChar(string $char): bool
108108
{
109-
return $this->getChar() === $char
110-
? !!++$this->position
111-
: false;
109+
return $this->getChar() === $char ? !!++$this->position : false;
112110
}
113111

114112
/**
@@ -258,11 +256,11 @@ private function readComment(): bool
258256
/**
259257
* Attempts to read an identifier
260258
*/
261-
private function readIdentifier(string $identifier, bool $isRequired = false): ?string
259+
private function readIdentifier(string $identifier, bool $throwIfNotFound = false): ?string
262260
{
263261
$this->readWhiteSpace();
264262
if (!$this->readString($identifier)) {
265-
if ($isRequired) {
263+
if ($throwIfNotFound) {
266264
throw new Exception("Expected identifier $identifier at byte {$this->position}");
267265
}
268266
return null;
@@ -286,7 +284,7 @@ private function readContext(): bool
286284
/**
287285
* Reads the original message
288286
*/
289-
private function readId(): void
287+
private function readOriginal(): void
290288
{
291289
$data = $this->readIdentifier('msgid', true);
292290
$this->translation = $this->translation->withOriginal($data);
@@ -321,11 +319,11 @@ private function readTranslation(): void
321319
/**
322320
* Attempts to read the pluralized translation
323321
*/
324-
private function readPluralTranslation(bool $isRequired = false): bool
322+
private function readPluralTranslation(bool $throwIfNotFound = false): bool
325323
{
326324
$this->readWhiteSpace();
327325
if (!$this->readString('msgstr')) {
328-
if ($isRequired) {
326+
if ($throwIfNotFound) {
329327
throw new Exception("Expected indexed msgstr at byte {$this->position}");
330328
}
331329
return false;

0 commit comments

Comments
 (0)