examples (123456.789):
+ *
+ * 0 - (123456) show only digits, no precision
+ * 0.00 - (123456.78) show only digits, 2 precision
+ * 0.0000 - (123456.7890) show only digits, 4 precision
+ * 0,000 - (123,456) show comma and digits, no precision
+ * 0,000.00 - (123,456.78) show comma and digits, 2 precision
+ * 0,0.00 - (123,456.78) shortcut method, show comma and digits, 2 precision
+ * To reverse the grouping (,) and decimal (.) for international numbers, add /i to the end.
+ * For example: 0.000,00/i
+ *
+ * @param {Number} v The number to format.
+ * @param {String} format The way you would like to format this text.
+ * @return {String} The formatted number.
+ */
+ number: function(v, format) {
+ if(!format){
+ return v;
+ }
+ v = Ext.num(v, NaN);
+ if (isNaN(v)){
+ return '';
+ }
+ var comma = ',',
+ dec = '.',
+ i18n = false,
+ neg = v < 0;
+
+ v = Math.abs(v);
+ if(format.substr(format.length - 2) == '/i'){
+ format = format.substr(0, format.length - 2);
+ i18n = true;
+ comma = '.';
+ dec = ',';
+ }
+
+ var hasComma = format.indexOf(comma) != -1,
+ psplit = (i18n ? format.replace(/[^\d\,]/g, '') : format.replace(/[^\d\.]/g, '')).split(dec);
+
+ if(1 < psplit.length){
+ v = v.toFixed(psplit[1].length);
+ }else if(2 < psplit.length){
+ throw ('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
+ }else{
+ v = v.toFixed(0);
+ }
+
+ var fnum = v.toString();
+ if(hasComma){
+ psplit = fnum.split('.');
+
+ var cnum = psplit[0], parr = [], j = cnum.length, m = Math.floor(j / 3), n = cnum.length % 3 || 3;
+
+ for(var i = 0; i < j; i += n){
+ if(i != 0){
+ n = 3;
+ }
+ parr[parr.length] = cnum.substr(i, n);
+ m -= 1;
+ }
+ fnum = parr.join(comma);
+ if(psplit[1]){
+ fnum += dec + psplit[1];
+ }
+ }
+
+ return (neg ? '-' : '') + format.replace(/[\d,?\.?]+/, fnum);
+ },
+
+ /**
+ * Returns a number rendering function that can be reused to apply a number format multiple times efficiently
+ * @param {String} format Any valid number format string for {@link #number}
+ * @return {Function} The number formatting function
+ */
+ numberRenderer : function(format){
+ return function(v){
+ return Ext.util.Format.number(v, format);
+ };
+ },
+
+ /**
+ * Selectively do a plural form of a word based on a numeric value. For example, in a template,
+ * {commentCount:plural("Comment")} would result in "1 Comment" if commentCount was 1 or would be "x Comments"
+ * if the value is 0 or greater than 1.
+ * @param {Number} value The value to compare against
+ * @param {String} singular The singular form of the word
+ * @param {String} plural (optional) The plural form of the word (defaults to the singular with an "s")
+ */
+ plural : function(v, s, p){
+ return v +' ' + (v == 1 ? s : (p ? p : s+'s'));
+ },
+
+ /**
+ * Converts newline characters to the HTML tag <br/>
+ * @param {String} The string value to format.
+ * @return {String} The string with embedded <br/> tags in place of newlines.
+ */
+ nl2br : function(v){
+ return v === undefined || v === null ? '' : v.replace(/\n/g, '