time() + 365 * 86400, 'path' => '/', 'secure' => is_https(), 'httponly' => false, 'samesite' => 'Lax', ]); } $_COOKIE[HUB_LOCALE_COOKIE] = $locale; } function hub_strings(): array { static $strings = null; if ($strings === null) { $strings = require HUB_APP . '/i18n_strings.php'; } return $strings; } /** Text in der aktuellen Sprache; unbekannte Schlüssel geben den Schlüssel zurück. */ function t(string $key, array $args = []): string { $strings = hub_strings(); $locale = hub_locale(); $text = $strings[$locale][$key] ?? $strings[HUB_DEFAULT_LOCALE][$key] ?? $key; if ($args !== []) { $replace = []; foreach ($args as $name => $value) { $replace['{' . $name . '}'] = (string) $value; } $text = strtr($text, $replace); } return $text; }