Skip to content

Commit 4f65cee

Browse files
Added new example for localize with objects
I've added a new example to illustrate on how to call localize by passing the response of a webservice as an argument to 'jquery-localize'. Both of the examples created for this new feature have been moved to a new 'objectDS' folder, as to keep them separated from the default examples.
1 parent 8094a54 commit 4f65cee

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
<h2 data-localize="app.name">Waiting for server response...</h2>
16+
<h3 data-localize="app.version">Waiting for server response...</h3>
17+
<p data-localize="app.description">
18+
Waiting for server response...
19+
</p>
20+
21+
<script type="text/javascript" charset="utf-8">
22+
$(function(){
23+
$.ajax({
24+
method: "GET",
25+
url: "res/ws-response",
26+
data: { lang: "en" },
27+
dataType: "json",
28+
success: function (data) {
29+
$("[data-localize]").localize(data);
30+
}
31+
});
32+
})
33+
</script>
34+
</body>
35+
36+
</html>

examples/localize_from_object.html renamed to examples/objectDS/localize_from_object.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
88
<title>Localize Test</title>
99
<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>
10+
<script src="../../dist/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
1111
</head>
1212

1313
<body>
@@ -20,7 +20,7 @@ <h1>Test localization...</h1>
2020
</optgroup>
2121
</select>
2222
<p>
23-
<img src="ruby_square.gif" alt="a square ruby" data-localize="test.ruby_image"/>
23+
<img src="../ruby_square.gif" alt="a square ruby" data-localize="test.ruby_image"/>
2424
Ruby image should be round.
2525
</p>
2626
<p data-localize="basic">It failed :(</p>
@@ -43,7 +43,7 @@ <h1>Test localization...</h1>
4343
"optgroup": "optgroup success",
4444
"option": "option success",
4545
"ruby_image": {
46-
"src": "ruby_round.gif",
46+
"src": "../ruby_round.gif",
4747
"alt": "a round ruby",
4848
"title": "A Round Ruby"
4949
},

examples/objectDS/res/ws-response

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"app": {
3+
"name": "MyApp",
4+
"version": "1.2",
5+
"description": "App using 'jquery-localize'"
6+
}
7+
}

0 commit comments

Comments
 (0)