feat: Website und Hub zweisprachig (Deutsch/Englisch)
Website (rinkplanner.programmschmiede.de) liegt jetzt im Repo unter web/: Sprachweiche nach Accept-Language (der User-Agent enthält keine Sprache), /de/ und /en/ als eigene URLs mit hreflang, Cookie für die manuelle Wahl, Texte in web/i18n.php, Markup in web/template.php. Deployment über tools/deploy_web.sh (--sync, --check, --all); /index.html leitet weiter. Hub: optionale englische Oberfläche über den DE/EN-Umschalter, Cookie RHUB_LANG, Route /language. Alle Texte (Views, Meldungen, Validierung, API-messages) stehen in hub/app/i18n_strings.php und laufen über t(); Datum und Zahlen folgen der Sprache. Die API behält ihre code-Felder und antwortet ohne Cookie weiter deutsch. deploy_hub.sh --check prüft jetzt Schlüsselparität und fehlende t()-Schlüssel. Doku: docs/website.md neu, docs/hub.md und AGENTS.md ergänzt.
This commit is contained in:
parent
6c8dc942e8
commit
9819311403
41 changed files with 2801 additions and 326 deletions
|
|
@ -90,7 +90,7 @@ function api_handle(string $method, string $path): void
|
|||
|
||||
if ($path === '/api/v1/tokens') {
|
||||
if ($method !== 'POST') {
|
||||
abort_api(405, 'method_not_allowed', 'Nur POST ist erlaubt.');
|
||||
abort_api(405, 'method_not_allowed', t('api.post_only'));
|
||||
}
|
||||
api_create_token();
|
||||
return;
|
||||
|
|
@ -100,7 +100,7 @@ function api_handle(string $method, string $path): void
|
|||
|
||||
if ($path === '/api/v1/me') {
|
||||
if ($method !== 'GET') {
|
||||
abort_api(405, 'method_not_allowed', 'Nur GET ist erlaubt.');
|
||||
abort_api(405, 'method_not_allowed', t('api.get_only'));
|
||||
}
|
||||
json_response([
|
||||
'id' => (int) $user['id'],
|
||||
|
|
@ -128,7 +128,7 @@ function api_handle(string $method, string $path): void
|
|||
if ($method === 'POST') {
|
||||
api_upload($user, null);
|
||||
}
|
||||
abort_api(405, 'method_not_allowed', 'Nur GET oder POST ist erlaubt.');
|
||||
abort_api(405, 'method_not_allowed', t('api.get_or_post'));
|
||||
}
|
||||
|
||||
if (preg_match('#^/api/v1/routines/(\d+)$#', $path, $matches) === 1) {
|
||||
|
|
@ -137,20 +137,20 @@ function api_handle(string $method, string $path): void
|
|||
}
|
||||
if (preg_match('#^/api/v1/routines/(\d+)/(download|audio)$#', $path, $matches) === 1) {
|
||||
if ($method !== 'GET') {
|
||||
abort_api(405, 'method_not_allowed', 'Nur GET ist erlaubt.');
|
||||
abort_api(405, 'method_not_allowed', t('api.get_only'));
|
||||
}
|
||||
$routine = api_fetch_visible((int) $matches[1], $user);
|
||||
routine_send_file($routine, (string) $matches[2], $user, true);
|
||||
}
|
||||
if (preg_match('#^/api/v1/routines/(\d+)/revisions$#', $path, $matches) === 1) {
|
||||
if ($method !== 'POST') {
|
||||
abort_api(405, 'method_not_allowed', 'Nur POST ist erlaubt.');
|
||||
abort_api(405, 'method_not_allowed', t('api.post_only'));
|
||||
}
|
||||
api_upload($user, (int) $matches[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
abort_api(404, 'not_found', 'Unbekannter API-Pfad.');
|
||||
abort_api(404, 'not_found', t('api.unknown_path'));
|
||||
}
|
||||
|
||||
function api_create_token(): void
|
||||
|
|
@ -160,7 +160,7 @@ function api_create_token(): void
|
|||
$password = (string) ($input['password'] ?? '');
|
||||
$name = trim((string) ($input['name'] ?? 'App'));
|
||||
if ($login === '' || $password === '') {
|
||||
abort_api(422, 'invalid_credentials', 'Benutzername und Passwort sind erforderlich.');
|
||||
abort_api(422, 'invalid_credentials', t('api.credentials_required'));
|
||||
}
|
||||
$result = auth_attempt($login, $password);
|
||||
if (!$result['ok']) {
|
||||
|
|
@ -172,7 +172,7 @@ function api_create_token(): void
|
|||
}
|
||||
$user = $result['user'];
|
||||
if ((int) ($user['must_change_password'] ?? 0) === 1) {
|
||||
abort_api(403, 'password_change_required', 'Bitte zuerst im Web das Passwort ändern.');
|
||||
abort_api(403, 'password_change_required', t('api.change_password_web'));
|
||||
}
|
||||
$created = token_create((int) $user['id'], $name);
|
||||
json_response([
|
||||
|
|
@ -191,10 +191,10 @@ function api_fetch_visible(int $id, array $user): array
|
|||
{
|
||||
$routine = routine_fetch($id);
|
||||
if ($routine === null) {
|
||||
abort_api(404, 'not_found', 'Kür nicht gefunden.');
|
||||
abort_api(404, 'not_found', t('routine.not_found_short'));
|
||||
}
|
||||
if (!routine_can_view($routine, $user)) {
|
||||
abort_api(403, 'forbidden', 'Diese Kür ist nicht freigegeben.');
|
||||
abort_api(403, 'forbidden', t('routine.forbidden'));
|
||||
}
|
||||
return $routine;
|
||||
}
|
||||
|
|
@ -207,26 +207,26 @@ function api_routine(int $id, string $method, array $user): void
|
|||
}
|
||||
if ($method === 'DELETE') {
|
||||
if (!routine_can_edit($routine, $user)) {
|
||||
abort_api(403, 'forbidden', 'Nur der Eigentümer oder ein Admin darf die Kür ändern.');
|
||||
abort_api(403, 'forbidden', t('api.edit_forbidden'));
|
||||
}
|
||||
routine_set_status($id, 'hidden');
|
||||
json_response(['id' => $id, 'status' => 'hidden']);
|
||||
}
|
||||
abort_api(405, 'method_not_allowed', 'Nur GET oder DELETE ist erlaubt.');
|
||||
abort_api(405, 'method_not_allowed', t('api.get_or_delete'));
|
||||
}
|
||||
|
||||
function api_upload(array $user, ?int $routineId): void
|
||||
{
|
||||
if (!api_truthy($_POST['rights'] ?? null)) {
|
||||
abort_api(422, 'rights_required', 'Bitte bestätigen, dass Kür und Musik geteilt werden dürfen.');
|
||||
abort_api(422, 'rights_required', t('api.rights_required'));
|
||||
}
|
||||
if (!routine_upload_quota_ok((int) $user['id'])) {
|
||||
abort_api(429, 'upload_limit', 'Stündliches Upload-Limit erreicht.');
|
||||
abort_api(429, 'upload_limit', t('api.upload_limit'));
|
||||
}
|
||||
$package = routine_validate_package($_POST);
|
||||
if (!$package['ok']) {
|
||||
json_response([
|
||||
'error' => ['code' => 'validation_failed', 'message' => 'Die Dateien sind nicht gültig.'],
|
||||
'error' => ['code' => 'validation_failed', 'message' => t('api.invalid_files')],
|
||||
'errors' => $package['errors'],
|
||||
], 422);
|
||||
}
|
||||
|
|
@ -234,22 +234,22 @@ function api_upload(array $user, ?int $routineId): void
|
|||
if ($routineId === null) {
|
||||
$duplicate = routine_duplicate_exists((int) $user['id'], $package);
|
||||
if ($duplicate !== null) {
|
||||
abort_api(409, 'duplicate', 'Diese Kür ist bereits im Hub (ID ' . $duplicate . ').');
|
||||
abort_api(409, 'duplicate', t('api.duplicate', ['id' => $duplicate]));
|
||||
}
|
||||
$routineId = routine_create((int) $user['id'], $package);
|
||||
} else {
|
||||
$routine = routine_fetch($routineId);
|
||||
if ($routine === null) {
|
||||
abort_api(404, 'not_found', 'Kür nicht gefunden.');
|
||||
abort_api(404, 'not_found', t('routine.not_found_short'));
|
||||
}
|
||||
if (!routine_can_edit($routine, $user)) {
|
||||
abort_api(403, 'forbidden', 'Nur der Eigentümer oder ein Admin darf die Kür ändern.');
|
||||
abort_api(403, 'forbidden', t('api.edit_forbidden'));
|
||||
}
|
||||
routine_add_revision($routineId, (int) $user['id'], $package);
|
||||
}
|
||||
$created = routine_fetch($routineId);
|
||||
if ($created === null) {
|
||||
abort_api(500, 'server_error', 'Kür konnte nicht geladen werden.');
|
||||
abort_api(500, 'server_error', t('api.routine_load_failed'));
|
||||
}
|
||||
json_response(api_routine_payload($created), 201);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue