Skip to content

Commit f86d01c

Browse files
Added new example by using a js object as a source
1 parent 5d89c7a commit f86d01c

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

examples/localize_from_object.html

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
4+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5+
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8+
<title>Localize Test</title>
9+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
10+
<script src="../dist/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
11+
</head>
12+
13+
<body>
14+
<h1>Test localization...</h1>
15+
<p data-localize="test.nested">puts 2 + 2</p>
16+
<input data-localize="test.input" type="text" value="fail" />
17+
<select>
18+
<optgroup data-localize="test.optgroup" label="Fail">
19+
<option data-localize="test.option" value="1">Fail</option>
20+
</optgroup>
21+
</select>
22+
<p>
23+
<img src="ruby_square.gif" alt="a square ruby" data-localize="test.ruby_image"/>
24+
Ruby image should be round.
25+
</p>
26+
<p data-localize="basic">It failed :(</p>
27+
<p data-localize="function">This text should remain unchanged</p>
28+
<script type="text/javascript" charset="utf-8">
29+
$(function(){
30+
var object = {
31+
"test": {
32+
"nested": "nested success",
33+
"input": "input success",
34+
"input_as_obj": {
35+
"value": "input_as_obj value success",
36+
"title": "input_as_obj title success"
37+
},
38+
"optgroup": "optgroup success",
39+
"option": "option success",
40+
"ruby_image": {
41+
"src": "ruby_round.gif",
42+
"alt": "a round ruby",
43+
"title": "A Round Ruby"
44+
},
45+
"link": {
46+
"text": "success",
47+
"href": "http://success"
48+
}
49+
},
50+
"basic": "basic success",
51+
"with_title": {
52+
"text": "with_title text success",
53+
"title": "with_title title success"
54+
},
55+
"function": function () {}
56+
};
57+
58+
$("[data-localize]").localize(object);
59+
})
60+
</script>
61+
</body>
62+
63+
</html>

0 commit comments

Comments
 (0)