83 lines
2.4 KiB
HTML
83 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>Basic Sample Usage</title>
|
|
|
|
<script src="http://code.jquery.com/jquery-1.7.min.js"></script>
|
|
<script src="../../bin/i18next-latest.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h3> you can switch lng via ?setLng='lngTag' </h3>
|
|
<a id="en" href="?setLng=en-US"> en-US </a>
|
|
|
|
|
<a id="de" href="?setLng=de-DE"> de-DE </a>
|
|
|
|
<h3>translated via $.t('app.name')</h3>
|
|
<span id="appname"></span> - <span id="apparea"></span>
|
|
<button id="add">hello</button>
|
|
|
|
<h5>with value insert $.t('app.insert', {youAre: 'great'})</h5>
|
|
<span id="insert"></span>
|
|
|
|
<h5>with plural $.t('app.insert', {youAre: 'great'})</h5>
|
|
<span id="singular"></span> - <span id="plural"></span>
|
|
|
|
<h5>nesting</h5>
|
|
<span id="nesting"></span>
|
|
|
|
<h5>with translation context $.t('friend_context', {context: 'male || female'})</h5>
|
|
<span id="male"></span> - <span id="female"></span>
|
|
|
|
|
|
<h3>loaded via attribute 'data-i18n' and $('.nav').i18n();</h3>
|
|
|
|
<h5>basic text</h5>
|
|
<ul class="nav">
|
|
<li class="active"><a href="#" data-i18n="nav.home"></a></li>
|
|
<li><a href="#" data-i18n="nav.1"></a></li>
|
|
<li><a href="#" data-i18n="nav.2"></a></li>
|
|
</ul>
|
|
|
|
<button id="btn" data-i18n="ns.common:add"></button>
|
|
|
|
<h5>extended usage of 'data-i18n' - apply to other attributes</h5>
|
|
<div id="extendedAttr">
|
|
<input data-i18n="[placeholder]ns.common:attr.placeholder;" type="text"></input>
|
|
<button data-i18n="[title]ns.common:attr.title;btn.hoverMe;"></button>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
$.i18n.init({
|
|
//lng: 'en-US',
|
|
ns: { namespaces: ['ns.common', 'ns.special'], defaultNs: 'ns.special'},
|
|
useLocalStorage: false,
|
|
debug: true
|
|
}, function(t) {
|
|
$('#add').text($.t('ns.common:add'));
|
|
$('#appname').text($.t('app.name'));
|
|
$('#apparea').text($.t('app.area'));
|
|
$('#insert').text($.t('app.insert', {youAre: 'great'}))
|
|
$('#singular').text($.t('app.child', {count: 1}))
|
|
$('#plural').text($.t('app.child', {count: 3}))
|
|
$('#nesting').text($.t('app.district'));
|
|
$('#male').text($.t('app.friend_context', {context: 'male'}))
|
|
$('#female').text($.t('app.friend_context', {context: 'female'}))
|
|
|
|
$('.nav').i18n();
|
|
$('#btn').i18n();
|
|
$('#extendedAttr').i18n();
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|