-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
57 lines (50 loc) · 1.42 KB
/
index.php
File metadata and controls
57 lines (50 loc) · 1.42 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello World PHP</title>
</head>
<body>
<?php
// Include the Translator class
require_once 'Translator.php';
// Include the InvisibleWrapper class
require_once 'InvisibleWrapper.php';
// Configure Tolgee API connection
$config = [
'apiUrl' => 'https://app.tolgee.io',
'language' => 'en',
'apiKey' => getenv('TOLGEE_API_KEY') ?: '', // Get API key from environment variable
'mode' => 'development'
];
// Create a new Translator instance with configuration
$translator = new Translator($config);
// Create a new InvisibleWrapper instance
$encoder = new InvisibleWrapper();
// Display some translated messages
echo "<h2>Translation Examples:</h2>";
echo "<ul>";
echo "<li>" . $translator->translate('welcome') . "</li>";
echo "</ul>";
?>
<script src="https://cdn.jsdelivr.net/npm/@tolgee/web/dist/tolgee-web.development.umd.min.js"></script>
<script>
const {Tolgee, DevTools, ObserverPlugin, DevBackend} = window['@tolgee/web'];
const tolgee = Tolgee()
.use(DevTools())
.use(ObserverPlugin())
.use(DevBackend())
.init({
language: 'en',
// for development mode
apiUrl: 'https://app.tolgee.io',
apiKey: '<?= $config['apiKey'] ?>',
observerOptions: {
fullKeyEncode: true
},
})
tolgee.run()
</script>
</body>
</html>