From b5af33407e511bd8f529ceeee056fc964136f933 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Wed, 14 Sep 2022 14:34:57 +0200 Subject: [PATCH] fixed localized sumas in search engine list --- .../app/Http/Controllers/SearchEngineList.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/metager/app/Http/Controllers/SearchEngineList.php b/metager/app/Http/Controllers/SearchEngineList.php index 5a67a5afd..4cdbdc43f 100644 --- a/metager/app/Http/Controllers/SearchEngineList.php +++ b/metager/app/Http/Controllers/SearchEngineList.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\App; +use App\Localization; +use LaravelLocalization; class SearchEngineList extends Controller { @@ -22,10 +22,20 @@ class SearchEngineList extends Controller if ($suma_file === null) { abort(404); } + + $locale = LaravelLocalization::getCurrentLocaleRegional(); + $lang = Localization::getLanguage(); $sumas = []; foreach ($suma_file->foki as $fokus_name => $fokus) { foreach ($fokus->sumas as $suma_name) { - $sumas[$fokus_name][] = $suma_name; + if ( + ## Lang support is not defined + (\property_exists($suma_file->sumas->{$suma_name}, "lang") && \property_exists($suma_file->sumas->{$suma_name}->lang, "languages") && \property_exists($suma_file->sumas->{$suma_name}->lang, "regions")) && + ## Current Locale/Lang is not supported by this engine + (\property_exists($suma_file->sumas->{$suma_name}->lang->languages, $lang) || \property_exists($suma_file->sumas->{$suma_name}->lang->regions, $locale)) + ) { + $sumas[$fokus_name][] = $suma_name; + } } } $suma_infos = []; -- GitLab