Files
BauIN/app/Http/Middleware/SetLocale.php
T
ChristophandClaude Opus 5.5 db2d5d6228 Mehrsprachigkeit der Oberfläche (Deutsch Standard, Englisch wählbar)
- Sprache je Benutzer (users.locale), Middleware SetLocale, Auswahl unter
  Einstellungen → Darstellung; angebotene Sprachen in config/app.php
- Übersetzungen über Laravel Lang (lang/de.json, lang/de/*.php), Seitentitel
  aus #[Title] werden übersetzt
- Eigene Texte und Korrekturen in lang/project/de.json, übernommen mit
  `artisan lang:apply-project` (überstehen `lang:update`)
- Tests: jede im Code verwendete Übersetzung ist vorhanden, eigene
  Übersetzungen sind übernommen, Sprachwahl und Standardsprache;
  SecurityTest prüft Texte sprachunabhängig über __()
- lang/ von Pint ausgenommen (erzeugte Dateien)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 09:52:20 +02:00

30 lines
725 B
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Symfony\Component\HttpFoundation\Response;
/**
* Setzt die Sprache der Oberfläche: die des angemeldeten Benutzers, sonst die Standardsprache.
*/
class SetLocale
{
public function handle(Request $request, Closure $next): Response
{
/** @var array<string, string> $available */
$available = config('app.available_locales');
$locale = $request->user()?->locale;
if (! is_string($locale) || ! array_key_exists($locale, $available)) {
$locale = config('app.locale');
}
App::setLocale($locale);
return $next($request);
}
}