Skip to content

Commit

Permalink
Merge pull request #81 from peter-gribanov/client_locale_docs
Browse files Browse the repository at this point in the history
Optimize docs for get GeoIP data in client locale
  • Loading branch information
peter-gribanov authored Jul 12, 2021
2 parents a5eb193 + 9664fc9 commit 5710d12
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ class GeoIPController
{
public function index(Request $request, ReaderFactory $factory): Response
{
$locale = $request->getLocale();
$ip = $request->getClientIp();
$client_locale = $request->getLocale();
$client_ip = $request->getClientIp();
$database_name = 'default';
$fallback_locale = 'en';
$reader = $factory->create('default', [$locale, 'en' /* fallback */]);
$record = $reader->city($ip);
$reader = $factory->create($database_name, [$client_locale, $fallback_locale]);
$record = $reader->city($client_ip);
return new Response(sprintf('You are from %s?', $record->country->name));
}
Expand Down

0 comments on commit 5710d12

Please sign in to comment.