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
Prev Previous commit
Next Next commit
Added new example by using a js object as a source
  • Loading branch information
LonelyPrincess committed Jul 8, 2017
commit f86d01c38388ff3a46d2cec15c841169b580ddb8
63 changes: 63 additions & 0 deletions examples/localize_from_object.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!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>
<p data-localize="test.nested">puts 2 + 2</p>
<input data-localize="test.input" type="text" value="fail" />
<select>
<optgroup data-localize="test.optgroup" label="Fail">
<option data-localize="test.option" value="1">Fail</option>
</optgroup>
</select>
<p>
<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>
<p data-localize="function">This text should remain unchanged</p>
<script type="text/javascript" charset="utf-8">
$(function(){
var object = {
"test": {
"nested": "nested success",
"input": "input success",
"input_as_obj": {
"value": "input_as_obj value success",
"title": "input_as_obj title success"
},
"optgroup": "optgroup success",
"option": "option success",
"ruby_image": {
"src": "ruby_round.gif",
"alt": "a round ruby",
"title": "A Round Ruby"
},
"link": {
"text": "success",
"href": "http://success"
}
},
"basic": "basic success",
"with_title": {
"text": "with_title text success",
"title": "with_title title success"
},
"function": function () {}
};

$("[data-localize]").localize(object);
})
</script>
</body>

</html>