-
Notifications
You must be signed in to change notification settings - Fork 610
/
index.php
82 lines (76 loc) · 2.13 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
require_once(__DIR__ . '/libs/translator.php');
$translator = new Translator();
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Translator</title>
</head>
<body>
<h3 style="margin: 10px 0;"><a href="">Translator</a></h3>
<form action="" method="post">
<b>Helpers</b>:
<input type="submit" name="action" value="Import" />
<input type="submit" name="action" value="Filter" />
<input type="submit" name="action" value="Translate manually" />
<input type="submit" name="action" value="Merge" />
<br /><br />
<b>Actions</b>:
<input type="submit" name="action" value="Generate empty.json" />
<input style="font-weight:bold;" type="submit" name="action" value="Auto Translate" />
<br /><br />
<?php
if (count($_POST) > 0) {
try {
if ($_POST['action'] == 'Import') {
$translator->scan();
$translator->extract();
echo "<pre>"; print_r($translator->strings); echo "</pre>\n";
}
if ($_POST['action'] == 'Filter') {
$translator->scan();
$translator->extract();
$translator->filter();
echo "<pre>"; print_r($translator->strings); echo "</pre>\n";
}
if ($_POST['action'] == 'Translate manually') {
//show form
$translator->prepare();
//translate
if (isset($_POST['in'])) {
$translation = $_POST['in'];
$translator->scan();
$translator->extract();
$translator->filter();
$translator->add_translation($translation);
$translator->show_merged();
}
}
if ($_POST['action'] == 'Merge') {
$translator->merge();
}
if ($_POST['action'] == 'Auto Translate') {
//prepare
$translator->scan();
$translator->extract();
$translator->filter();
$translator->auto_translate();
}
if ($_POST['action'] == 'Generate empty.json') {
//prepare
$translator->scan();
$translator->extract();
$translator->filter();
$translator->save_empty();
}
}
catch (Exception $exc) {
echo '<div style="margin-top:10px;color:red;">ERROR: ' . $exc->getMessage() . '</div>';
}
}
?>
</form>
</body>
</html>