Skip to content

Commit

Permalink
Merge pull request #25 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
Fixed determination of localization by the heading
  • Loading branch information
andrey-helldar authored Feb 16, 2025
2 parents c364cae + cfba8a3 commit c1d40ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/Middlewares/LocalizationByHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ protected function detect(Request $request): bool|float|int|string|null
return null;
}

return Locales::isInstalled(
$this->strBefore($value, [',', ';'])
);
if (! Locales::isInstalled($this->strBefore($value, [',', ';']))) {
return null;
}

return $value;
}

protected function strBefore(string $value, array $search): string
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Middlewares/HeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
->assertSuccessful()
->assertJsonPath($foo, LocaleValue::TranslationFrench);

assertEventDispatched();
assertEventNotDispatched();
})->with('uninstalled-locales');

test('unknown locale', function (int|string $locale) {
Expand All @@ -64,5 +64,5 @@
->assertSuccessful()
->assertJsonPath($foo, LocaleValue::TranslationFrench);

assertEventDispatched();
assertEventNotDispatched();
})->with('unknown-locales');

0 comments on commit c1d40ff

Please sign in to comment.