-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
52 lines (52 loc) · 1.9 KB
/
index.php
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
43
44
45
46
47
48
49
50
51
52
<?php
Kirby::plugin('mountbatt/deepl', [
'fields' => [
'deepl' => [
'props' => [
'csrf' => function () {
return kirby()->csrf();
},
'page_id' => function () {
return str_replace('/', '+', $this->model()->id());
},
'field_name' => function () {
return $this->name();
}
]
]
],
'api' => [
'routes' => [
[
'pattern' => 'deepl',
'method' => 'POST',
'action' => function () {
$url = option('mountbatt.deepl.config.api_url');
$data = json_decode(file_get_contents("php://input"), true);
$options = [
'headers' => [
'Authorization: DeepL-Auth-Key ' . option('mountbatt.deepl.config.api_key'),
'Content-Type: application/x-www-form-urlencoded'
],
'method' => 'POST',
'data' => http_build_query($data)
];
$response = Remote::request($url, $options);
return $response->content();
}
]
]
],
'translations' => [
'en' => [
'mountbatt.deepl.import' => 'Import from',
'mountbatt.deepl.translatenow' => "Translate now with DeepL",
'mountbatt.deepl.importhelp' => "Loads the value of the field from the original language"
],
'de' => [
'mountbatt.deepl.import' => 'Importiere von',
'mountbatt.deepl.translatenow' => "Übersetze jetzt mit DeepL",
'mountbatt.deepl.importhelp' => "Lädt den Wert des Feldes aus der Originalsprache"
]
]
]);