forked from fabi1cazenave/webL10n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
103 lines (103 loc) · 3.35 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title> webL10n test page </title>
<meta charset="utf-8" />
<link rel="resource" type="application/l10n" href="locales.ini" />
<script type="text/javascript" src="l10n.js"></script>
<script type="text/javascript">
function onLocalized() {
var l10n = document.webL10n,
textProp = document.body.textContent ? 'textContent' : 'innerText';
document.getElementsByTagName('select')[0].value = l10n.getLanguage();
document.getElementById('l10n').getElementsByTagName('textarea')[0][textProp] =
l10n.getText();
document.getElementById('json').getElementsByTagName('textarea')[0][textProp] =
window.JSON ? JSON.stringify(l10n.getData(), undefined, 2) : 'no JSON support';
};
if (document.addEventListener) {
window.addEventListener('localized', onLocalized, false);
} else {
document.documentElement.localized = 0;
document.documentElement.attachEvent('onpropertychange', function(e) {
if (e.propertyName === 'localized')
onLocalized();
});
}
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
#test {
margin: 2em;
}
#test div {
max-width: 600px;
margin: 1em auto;
padding: 0 1em;
border: 1px dashed black;
}
#data p {
height: 1em;
margin: 0;
}
textarea[readonly] {
background-color: #eee;
}
</style>
<!--[if lte IE 9]>
<style type="text/css">
/* IE<10 doesn't support CSS flex-box... */
#l10n { width: 50%; position: absolute; left: 0.5%; }
#json { width: 50%; position: absolute; right: 0; }
</style>
<![endif]-->
</head>
<body>
<nav>
<a href="https://github.com/fabi1cazenave/webL10n"><img
style="position: absolute; top: 0; right: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"
alt="Fork me on GitHub"
/></a>
</nav>
<div id="test">
<div>
<p data-l10n-id="about">This section is translated dynamically</p>
<p style="text-align: center;">
<span data-l10n-id="Phone" title="phone">Phone</span>
<span data-l10n-id="Calculator">Calculator</span>
<span data-l10n-id="Music">Music</span>
<span data-l10n-id="Books">Books</span>
<span data-l10n-id="Calendar" title="calendar">Calendar</span>
<br />
<button data-l10n-id="hello" accesskey="h" title="click"
onclick="alert(_('sayHello'));">Hello!</button>
</p>
<p data-l10n-id="Children">
Translate a node with children
<span data-l10n-id="Child">I'm a child</span>
</p>
<p style="text-align: right;">
<span data-l10n-id="langSelection">language selection</span>
<select onchange="document.webL10n.setLanguage(this.value || this.options[this.selectedIndex].text);">
<option disabled selected> </option>
<option>en</option>
<option>fr</option>
<option>de</option>
<option>sq</option>
</select>
</p>
</div>
</div>
<div id="data">
<div id="l10n">
<p> l10n resources: </p>
<textarea readonly rows="24" cols="80"></textarea>
</div>
<div id="json">
<p> parsed data: </p>
<textarea readonly rows="24" cols="80"></textarea>
</div>
</div>
</body>
</html>