-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_language.php
More file actions
42 lines (36 loc) · 971 Bytes
/
set_language.php
File metadata and controls
42 lines (36 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* API zum Setzen der Sprache
* Dateipfad: /image-compressor/set_language.php
*/
session_start();
require_once 'config/config.php';
require_once 'config/lang_config.php';
header('Content-Type: application/json; charset=utf-8');
// Prüfe Request-Methode
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['error' => 'Method not allowed']);
exit;
}
// Hole Sprache aus Request
$lang = $_POST['lang'] ?? null;
if (!$lang) {
http_response_code(400);
echo json_encode(['error' => 'No language specified']);
exit;
}
// Setze Sprache
if (setLanguage($lang)) {
echo json_encode([
'success' => true,
'language' => $lang,
'message' => __('app.title') // Test-Übersetzung
]);
} else {
http_response_code(400);
echo json_encode([
'error' => 'Invalid language',
'available' => AVAILABLE_LANGUAGES
]);
}