Skip to content

Localize from object #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
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.
  • Loading branch information
LonelyPrincess committed Jul 9, 2017
commit 4f65cee22be5eee0d15eed0df875dfbf743de507
36 changes: 36 additions & 0 deletions examples/objectDS/localize_from_external_ws.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Localize Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../dist/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<h1>Test localization...</h1>
<h2 data-localize="app.name">Waiting for server response...</h2>
<h3 data-localize="app.version">Waiting for server response...</h3>
<p data-localize="app.description">
Waiting for server response...
</p>

<script type="text/javascript" charset="utf-8">
$(function(){
$.ajax({
method: "GET",
url: "res/ws-response",
data: { lang: "en" },
dataType: "json",
success: function (data) {
$("[data-localize]").localize(data);
}
});
})
</script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Localize Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../dist/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../dist/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
Expand All @@ -20,7 +20,7 @@ <h1>Test localization...</h1>
</optgroup>
</select>
<p>
<img src="ruby_square.gif" alt="a square ruby" data-localize="test.ruby_image"/>
<img src="../ruby_square.gif" alt="a square ruby" data-localize="test.ruby_image"/>
Ruby image should be round.
</p>
<p data-localize="basic">It failed :(</p>
Expand All @@ -43,7 +43,7 @@ <h1>Test localization...</h1>
"optgroup": "optgroup success",
"option": "option success",
"ruby_image": {
"src": "ruby_round.gif",
"src": "../ruby_round.gif",
"alt": "a round ruby",
"title": "A Round Ruby"
},
Expand Down
7 changes: 7 additions & 0 deletions examples/objectDS/res/ws-response
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"app": {
"name": "MyApp",
"version": "1.2",
"description": "App using 'jquery-localize'"
}
}