siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
76 lines (58 loc) • 2.08 kB
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js">/*
Siesta 5.6.1
Copyright(c) 2009-2022 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license
*/
// Localization helper
Siesta.Resource = (function () {
var cacheByNamespace = {}
var Resource = Class({
does : Siesta.Util.Role.CanFormatStrings,
has : {
dict : null
},
methods : {
'get' : function (key, data) {
var text = this.dict[ key ];
if (text) return this.formatString(text, data);
if (window.console && console.error) {
window.top.console.error('TEXT_NOT_DEFINED: ' + key);
}
return 'TEXT_NOT_DEFINED: ' + key;
}
}
})
return function (namespace, key, data) {
var dictionary = Siesta.CurrentLocale[ namespace ];
if (!dictionary) {
throw 'Missing dictionary for namespace: ' + namespace;
}
var resource = cacheByNamespace[ namespace ]
if (!resource) {
resource = cacheByNamespace[ namespace ] = new Resource({ dict : dictionary, serializeFormatingPlaceholders : false })
}
if (key) return resource.get(key, data)
return resource
}
})();
</pre>
</body>
</html>