aside anapssungen

This commit is contained in:
2026-03-05 13:07:43 +01:00
parent b2dab5bd6c
commit 9819cba733
4 changed files with 24 additions and 6 deletions

View File

@@ -42,7 +42,15 @@ $publicTarget = ltrim($publicTarget, '/');
<?php foreach ($locales as $locale): ?>
<?php
$isActive = $locale === I18n::$locale;
$label = strtoupper((string) $locale);
$normalizedLocale = strtolower(trim((string) $locale));
if (strpos($normalizedLocale, '-') !== false) {
$normalizedLocale = explode('-', $normalizedLocale, 2)[0];
}
$languageLabels = [
'de' => t('German'),
'en' => t('English'),
];
$label = $languageLabels[$normalizedLocale] ?? strtoupper((string) $locale);
$publicUrl = $base . '/' . $locale . ($publicTarget !== '' ? '/' . $publicTarget : '');
$switchUrl = $isLoggedIn
? ($baseUrl . '?locale=' . $locale . '&return=' . urlencode($returnTarget))
@@ -52,7 +60,7 @@ $publicTarget = ltrim($publicTarget, '/');
<a href="<?php e($switchUrl); ?>"
class="<?php e($isActive ? 'active' : ''); ?>"
<?php if ($isActive) { ?>aria-current="true"<?php } ?>>
<?php e(t('Language')); ?>: <?php e($label); ?>
<?php e($label); ?>
</a>
</li>
<?php endforeach; ?>