Commit 6373a817 authored by Sven Franck's avatar Sven Franck

updated 3rd party plugins to latest version

parent 3da91715
// i18next, v1.7.1
// Copyright (c)2013 Jan Mühlemann (jamuhl).
// i18next, v1.7.2
// Copyright (c)2014 Jan Mühlemann (jamuhl).
// Distributed under MIT license
// http://i18next.com
(function() {
......@@ -103,6 +103,7 @@
detectLngQS: 'setLng',
ns: 'translation',
fallbackOnNull: true,
fallbackOnEmpty: false,
fallbackToDefaultNS: false,
nsseparator: ':',
keyseparator: '.',
......@@ -141,6 +142,7 @@
cookieName: 'i18next',
cookieDomain: undefined,
objectTreeKeyHandler: undefined,
postProcess: undefined,
parseMissingKey: undefined,
......@@ -545,7 +547,7 @@
var f = {
extend: $ ? $.extend : _extend,
each: $ ? $.each : _each,
ajax: $ ? $.ajax : _ajax,
ajax: $ ? $.ajax : (typeof document !== 'undefined' ? _ajax : function() {}),
cookie: typeof document !== 'undefined' ? _cookie : cookie_noop,
detectLanguage: detectLanguage,
escape: _escape,
......@@ -692,6 +694,15 @@
f.extend(resStore[lng][ns], resources);
}
function removeResourceBundle(lng, ns) {
if (typeof ns !== 'string') {
ns = o.ns.defaultNs;
}
resStore[lng] = resStore[lng] || {};
resStore[lng][ns] = {};
}
function setDefaultNamespace(ns) {
o.ns.defaultNs = ns;
}
......@@ -770,7 +781,10 @@
if (typeof options === 'function') {
cb = options;
options = {};
} else if (!options) {
options = {};
}
options.lng = lng;
return init(options, cb);
}
......@@ -801,10 +815,15 @@
if (attr === 'html') {
optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options;
ele.html($.t(key, optionsToUse));
}
else if (attr === 'text') {
} else if (attr === 'text') {
optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.text() }, options) : options;
ele.text($.t(key, optionsToUse));
} else if (attr === 'prepend') {
optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options;
ele.prepend($.t(key, optionsToUse));
} else if (attr === 'append') {
optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.html() }, options) : options;
ele.append($.t(key, optionsToUse));
} else {
optionsToUse = o.defaultValueFromContent ? $.extend({ defaultValue: ele.attr(attr) }, options) : options;
ele.attr(attr, $.t(key, optionsToUse));
......@@ -922,7 +941,7 @@
}
function hasContext(options) {
return (options.context && typeof options.context == 'string');
return (options.context && (typeof options.context == 'string' || typeof options.context == 'number'));
}
function needsPlural(options) {
......@@ -939,6 +958,8 @@
}
function translate(key, options) {
options = options || {};
if (!initialized) {
f.log('i18next not finished initialization. you might have called t function before loading resources finished.')
return options.defaultValue || '';
......@@ -980,18 +1001,22 @@
options = options || {};
}
if (potentialKeys === undefined || potentialKeys === null) return '';
if (typeof potentialKeys == 'string') {
potentialKeys = [potentialKeys];
}
var key = null;
var key = potentialKeys[0];
if (potentialKeys.length > 1) {
for (var i = 0; i < potentialKeys.length; i++) {
key = potentialKeys[i];
if (exists(key)) {
break;
}
}
}
var notFound = _getDefaultValue(key, options)
, found = _find(key, options)
......@@ -1044,7 +1069,7 @@
return (found !== undefined) ? found : notFound;
}
function _find(key, options){
function _find(key, options) {
options = options || {};
var optionWithoutCount, translated
......@@ -1124,10 +1149,11 @@
x++;
}
if (value !== undefined) {
var valueType = Object.prototype.toString.apply(value);
if (typeof value === 'string') {
value = applyReplacement(value, options);
value = applyReuse(value, options);
} else if (Object.prototype.toString.apply(value) === '[object Array]' && !o.returnObjectTrees && !options.returnObjectTrees) {
} else if (valueType === '[object Array]' && !o.returnObjectTrees && !options.returnObjectTrees) {
value = value.join('\n');
value = applyReplacement(value, options);
value = applyReuse(value, options);
......@@ -1135,17 +1161,25 @@
value = undefined;
} else if (value !== null) {
if (!o.returnObjectTrees && !options.returnObjectTrees) {
if (o.objectTreeKeyHandler && typeof o.objectTreeKeyHandler == 'function') {
value = o.objectTreeKeyHandler(key, value, l, ns, options);
} else {
value = 'key \'' + ns + ':' + key + ' (' + l + ')\' ' +
'returned a object instead of string.';
'returned an object instead of string.';
f.log(value);
} else if (typeof value !== 'number') {
var copy = {}; // apply child translation on a copy
}
} else if (valueType !== '[object Number]' && valueType !== '[object Function]' && valueType !== '[object RegExp]') {
var copy = (valueType === '[object Array]') ? [] : {}; // apply child translation on a copy
f.each(value, function(m) {
copy[m] = _translate(ns + o.nsseparator + key + o.keyseparator + m, options);
});
value = copy;
}
}
if (typeof value === 'string' && value.trim() === '' && o.fallbackOnEmpty === true)
value = undefined;
found = value;
}
}
......@@ -1345,7 +1379,15 @@
done(null, data);
},
error : function(xhr, status, error) {
f.log('failed loading: ' + url);
if (error.status == 200) {
// file loaded but invalid json, stop waste time !
f.log('There is a typo in: ' + url);
} else if (error.status == 404) {
f.log('Does not exist: ' + url);
} else {
f.log(error.status + ' when loading ' + url);
}
done(error, {});
},
dataType: "json",
......@@ -2645,6 +2687,7 @@
i18n.setLng = setLng;
i18n.preload = preload;
i18n.addResourceBundle = addResourceBundle;
i18n.removeResourceBundle = removeResourceBundle;
i18n.loadNamespace = loadNamespace;
i18n.loadNamespaces = loadNamespaces;
i18n.setDefaultNamespace = setDefaultNamespace;
......
This diff is collapsed.
......@@ -29,14 +29,15 @@
<script type="text/javascript" src="ext/libs/jio/erp5storage.js"></script>
<!-- 3rd party plugins -->
<script type="text/javascript" src="js/plugins/state/state.js"></script>
<script type="text/javascript" src="js/plugins/validval/jquery.validVal.js"></script>
<script type="text/javascript" src="js/plugins/i18next/i18next.js"></script>
<script type="text/javascript" src="js/plugins/modernizr/modernizr.js"></script>
<script type="text/javascript" src="js/plugins/selectivzr/selectivzr.js"></script>
<script type="text/javascript" src="js/plugins/hellojs/hellojs.js"></script>
<!-- <script type="text/javascript" src="js/plugins/jspdf/jspdf.js"></script> -->
<script type="text/javascript" src="js/shims.js"></script>
<script type="text/javascript" src="ext/plugins/modernizr/modernizr.js"></script>
<script type="text/javascript" src="ext/plugins/state/state.js"></script>
<script type="text/javascript" src="ext/plugins/validval/jquery.validVal.js"></script>
<script type="text/javascript" src="ext/plugins/i18next/i18next.js"></script>
<script type="text/javascript" src="ext/plugins/hellojs/hellojs.js"></script>
<!-- <script type="text/javascript" src="ext/plugins/jspdf/jspdf.js"></script> -->
<!-- IE8 and worse -->
<!-- <script type="text/javascript" src="ext/plugins/selectivzr/selectivzr.js"></script> -->
<!-- stuff happens here -->
<script type="text/javascript" data-storage="data/storages.json" data-config="data/global.json" src="js/erp5_loader.js"></script>
......
This diff is collapsed.
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true, todo: true */
/*global console, window, document */
(function (window, document) {
"use strict";
// NOTE: old browsers need all of these
var shim_dict = {};
/* ====================================================================== */
/* SHIMS */
/* ====================================================================== */
// NOTE: add more: https://github.com/kriskowal/es5-shim
// NOTE: to support IE8+/Windows Mobile where possible, test via modernizr
// =============================== indexOf ================================
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(searchElement /*, fromIndex */) {
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (len === 0)
return -1;
var n = 0;
if (arguments.length > 0)
{
n = Number(arguments[1]);
if (n !== n)
n = 0;
else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0))
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
if (n >= len)
return -1;
var k = n >= 0
? n
: Math.max(len - Math.abs(n), 0);
for (; k < len; k++)
{
if (k in t && t[k] === searchElement)
return k;
}
return -1;
};
}
// =============================== BASE64 encoding ========================
// https://gist.github.com/yahiko/229984
shim_dict.Base64 = {
characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ,
/**
* Shim for atob (not available on IE8+9+Windows Mobile?)
* @method Base64.encode
* @param {string} string String to be hashed
* @return {string} encoded string
*/
encode: function( string ) {
var characters = shim_dict.Base64.characters;
var result = '';
var i = 0;
do {
var a = string.charCodeAt(i++);
var b = string.charCodeAt(i++);
var c = string.charCodeAt(i++);
a = a ? a : 0;
b = b ? b : 0;
c = c ? c : 0;
var b1 = ( a >> 2 ) & 0x3F;
var b2 = ( ( a & 0x3 ) << 4 ) | ( ( b >> 4 ) & 0xF );
var b3 = ( ( b & 0xF ) << 2 ) | ( ( c >> 6 ) & 0x3 );
var b4 = c & 0x3F;
if( ! b ) {
b3 = b4 = 64;
} else if( ! c ) {
b4 = 64;
}
result += characters.charAt( b1 ) + characters.charAt( b2 ) +
characters.charAt( b3 ) + characters.charAt( b4 );
} while ( i < string.length );
return result;
},
/**
* Shim for btoa (not available on IE8+9+Windows Mobile?)
* @method Base64.decode
* @param {string} string String to be hashed
* @return {string} encoded string
*/
decode: function( string ) {
var characters = shim_dict.Base64.characters;
var result = '';
var i = 0;
do {
var b1 = characters.indexOf( string.charAt(i++) );
var b2 = characters.indexOf( string.charAt(i++) );
var b3 = characters.indexOf( string.charAt(i++) );
var b4 = characters.indexOf( string.charAt(i++) );
var a = ( ( b1 & 0x3F ) << 2 ) | ( ( b2 >> 4 ) & 0x3 );
var b = ( ( b2 & 0xF ) << 4 ) | ( ( b3 >> 2 ) & 0xF );
var c = ( ( b3 & 0x3 ) << 6 ) | ( b4 & 0x3F );
result += String.fromCharCode(a) + (b?String.fromCharCode(b):'') + (c?String.fromCharCode(c):'');
} while( i < string.length );
return result;
}
};
window.shim = shim_dict;
}(window, document));
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment