function ilang(var1, var2, var3) { // Check if the second or third parameter is NULL in order to know how deep is your array. if (var2 === undefined && var3 === undefined && lang[var1] !== undefined) text = lang[var1]; else if (var3 === undefined && var2 !== undefined && typeof var1 === 'string' && typeof lang[var1][var2] !== undefined) text = lang[var1][var2]; else if (var3 === undefined && typeof var1 !== 'string' && typeof lang[var2] !== undefined) text = lang[var2]; else if (var3 !== undefined && var2 !== undefined && var1 !== undefined && typeof lang[var2][var3] !== undefined) text = lang[var2][var3]; else return null; while (text.match(/{%(\w+)%}/) || text.match(/{{(\w+)}}/)) { if (text.match(/{%(\w+)%}/) && (typeof var1 === 'array' || typeof var1 === 'object')) text = local_var(var1, text); else return null; if (text.match(/{{(\w+)}}/)) text = lang_var(lang, text); } return bbcode(text); } function local_var(data, text) { while (res = text.match(/{%(\w+)%}/)) { new_var = ""; if (typeof data[res[1]] === 'string') new_var = data[res[1]]; text = text.replace(res[0], new_var); } return text; } function lang_var(data, text) { while (res = text.match(/{{(\w+)}}/)) { new_var = ""; if (typeof data[res[1]] === 'string') new_var = data[res[1]]; text = text.replace(res[0], new_var); } return text; } function make_price(price, decimals) { if (typeof decimals === 'undefined') decimals = true; else decimals = false; var separator = lang['price']['decimals']; var thousands_separator = lang['price']['thousands']; var decimals_value = 2; if (parseInt(price) == parseFloat(price) && (decimals != true || disable_decimal_price == true)) decimals_value = 0; price = number_format(price, decimals_value, separator, thousands_separator); var data = {price: price}; price = ilang(data, 'price', 'syntax'); return price; } function number_format(number, decimals, dec_point, thousands_sep) { number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point, s = '', toFixedFix = function (n, prec) { var k = Math.pow(10, prec); return '' + (Math.round(n * k) / k) .toFixed(prec); }; // Fix for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); } if ((s[1] || '').length < prec) { s[1] = s[1] || ''; s[1] += new Array(prec - s[1].length + 1).join('0'); } return s.join(dec); } function bbcode(str) { str = str.replace(/\[b\](.*?)\[\/b\]/gi, '$1'); str = str.replace(/\[i\](.*?)\[\/i\]/gi, '$1'); str = str.replace(/\[u\](.*?)\[\/u\]]/gi, '$1$1'); str = str.replace(/\[quote\](.*?)\[\/quote\]/gi, '
$1'); str = str.replace(/\[size=([0-9]+)\](.*?)\[\/size\]/gi, '$2'); str = str.replace(/\[color=\/?([A-F0-9]{3}|[A-F0-9]{6})\](.*?)\[\/color\]/gi, '$2'); str = str.replace(/\[url=(.*?)\](.*?)\[\/url\]/gi, '$2'); return str; }