Skip to content

Commit

Permalink
Use base language identifier in cases like zh-hant, zh-hans and pt-br.
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismeonmounteverest committed Oct 22, 2023
1 parent 818853a commit 0725c77
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Model/SuggestLocationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ private function getPlacesExact(string $term, int $limit, ?string $translationId

$query = $this->getQueryForGeonamesRt();
$matchQuery = new MatchPhrase($parts[0], 'name');

$locale = $this->adaptLocale($this->translator->getLocale());

$localeQuery = new BoolQuery();
$localeQuery->should(new Equals('locale', '_geo'));
$localeQuery->should(new Equals('locale', $this->translator->getLocale()));

$localeQuery->should(new Equals('locale', $locale));
$filterElements = ['country', 'admin1', 'admin2', 'admin3', 'admin4'];
$adminUnitFilterQuery = new BoolQuery();
foreach ($adminUnits as $adminUnit) {
Expand Down Expand Up @@ -579,4 +583,9 @@ private function getQueryForGeonamesRt(): Search

return $query;
}

private function adaptLocale(string $locale)
{
return substr($locale, 0, 2);
}
}

0 comments on commit 0725c77

Please sign in to comment.