This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
editor.php
112 lines (96 loc) · 3.34 KB
/
editor.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
spl_autoload_register(function($className)
{
$namespace=str_replace("\\","/",__NAMESPACE__);
$className=str_replace("\\","/",$className);
$class="classes/".(empty($namespace)?"":$namespace."/")."{$className}.php";
include_once($class);
});
try {
$locale = $_GET['locale'];
$type = $_GET['type'];
$reactIntlEditor = new \ReactIntlEditor\ReactIntlEditor($locale);
switch ($type) {
case 'matching':
$stringsArray = $reactIntlEditor->getMatchingStrings();
break;
case 'missing':
$stringsArray = $reactIntlEditor->getMissingStrings();
break;
default:
throw new \ReactIntlEditor\Exception('Unknown String Type Specified in Querystring');
break;
}
} catch (\ReactIntlEditor\Exception $e) {
echo '<div style="color:black;border:3px solid red;padding:15px;max-width:800px;width:100%;">';
echo '<p>An error has occured during startup:</p><p>' . $e->getMessage() . '</p>';
echo '</div>';
die();
}
?><html lang="en">
<head>
<title>React Intl Editor</title>
<link rel="stylesheet" href="assets/react-intl-editor.css" />
</head>
<body>
<div class="wrapper">
<header>
<h1>React Intl Editor</h1>
<h2><?php echo $locale; ?></h2>
</header>
<main>
<form method="post" action="save_changes.php">
<input type="hidden" name="locale" value="<?php echo $locale;?>" />
<input type="hidden" name="type" value="<?php echo $type;?>" />
<div class="submitbar">
<button class="submitbutton">Save Changes</button>
</div>
<?php $i=0; foreach ($stringsArray as $string) { ?>
<table class="translate_item" id="translate-table-<?php echo $i; ?>">
<thead>
<tr>
<td><span class="key"></strong><?php echo ($type == 'missing') ? $string->id : $string['id']; ?></span></td>
<td></td>
<td>Translated Text for <?php echo $locale; ?> locale</td>
</tr>
</thead>
<tbody>
<tr>
<td class="original">
<p><span id="original-<?php echo $i;?>"><?php echo ($type == 'missing') ? $string->defaultMessage : $string['defaultMessage']; ?></span></p>
</td>
<td>
<button class="copybutton" data-id="<?php echo $i; ?>">Copy ></button>
</td>
<td>
<textarea class="translation" name="<?php echo ($type == 'missing') ? $string->id : $string['id']; ?>" id="translation-<?php echo $i; ?>"><?php if ($type == 'matching') { echo ($type == 'matching') ? $string['message'] : ''; } ?></textarea>
</td>
</tr>
</tbody>
<?php if ( ($type == 'matching' && $string['description'] !== null && $string['description'] !== $string['defaultMessage']) || ($type == 'missing' && $string->description !== null && $string->description !== $string->defaultMessage) ) { ?>
<tfoot>
<tr>
<td colspan="3">
<strong>Context:</strong><br /><?php echo ($type == 'missing') ? $string->description : $string['description'] ?>
</td>
</tr>
</tfoot>
<?php } ?>
</table>
<?php
$i++;
}
?>
<div class="submitbar">
<button class="submitbutton">Save Changes</button>
</div>
</form>
</main>
<footer>
<hr />
<a href="https://github.com/shawnhooper/react-intl-editor">React Intl Editor on GitHub</a>
</footer>
</div>
<script type="text/javascript" src="assets/editor.js"></script>
</body>
</html>