-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
51 lines (37 loc) · 1.23 KB
/
index.php
File metadata and controls
51 lines (37 loc) · 1.23 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
<?php
// include localization class
include 'localization.php';
$localization = Localization::instance();
?>
<html lang="<?php echo $localization->getCurrentLanguage(); ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><?php echo __('Site title'); ?></title>
<script>
/* method getJson() can be used for javascript translations */
var translations = <?php echo $localization->getJson(['Welcome to our site']); ?>;
console.log(translations['Welcome to our site']);
</script>
</head>
<body>
<h1><?php echo __('Welcome to our site'); ?></h1>
<hr />
<ul>
<?php foreach($localization->getLanguages() as $code => $name): ?>
<li>
<a href="?language=<?php echo $code; ?>"><?php echo $name; ?></a>
</li>
<?php endforeach; ?>
</ul>
<hr />
Usage:
<?php echo __('Current language key code is %s', [$localization->getCurrentLanguage()]); ?>
<br /><br />
or
<?php echo __('Translate function can take multiple params like %s and %s', ['this', 'that']); ?>
<br /><br />
or
<?php echo Localization::instance()->translate('Welcome to our site'); ?> ;
<br /><br />
</body>
</html>