Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Issue 5836 (Numbers formatting doesn't respect locale settings)

  • Loading branch information...
commit ba6057bfda54d8cd32a131626cebbd48a8ea6ec5 1 parent ffe9c81
Sebastian Zartner authored August 20, 2012
25  extension/content/firebug/lib/string.js
@@ -630,17 +630,12 @@ Str.cleanIndentation = function(text)
630 630
 // ************************************************************************************************
631 631
 // Formatting
632 632
 
633  
-Str.formatNumber = function(number)
634  
-{
635  
-    number += "";
636  
-    var x = number.split(".");
637  
-    var x1 = x[0];
638  
-    var x2 = x.length > 1 ? "." + x[1] : "";
639  
-    var rgx = /(\d+)(\d{3})/;
640  
-    while (rgx.test(x1))
641  
-        x1 = x1.replace(rgx, "$1" + "," + "$2");
642  
-    return x1 + x2;
643  
-}
  633
+
  634
+//deprecated compatibility functions
  635
+Str.deprecateEscapeHTML = createSimpleEscape("text", "normal");
  636
+
  637
+Str.formatNumber = Deprecated.deprecated("use <number>.toLocaleString() instead",
  638
+    function(number) { return number.toLocaleString(); });
644 639
 
645 640
 Str.formatSize = function(bytes)
646 641
 {
@@ -670,13 +665,13 @@ Str.formatSize = function(bytes)
670 665
     if (bytes == -1 || bytes == undefined)
671 666
         return "?";
672 667
     else if (bytes == 0)
673  
-        return "0";
  668
+        return "0 B";
674 669
     else if (bytes < 1024)
675  
-        result = bytes + " B";
  670
+        result = bytes.toLocaleString() + " B";
676 671
     else if (bytes < (1024*1024))
677  
-        result = Math.round((bytes/1024)*a)/a + " KB";
  672
+        result = (Math.round((bytes/1024)*a)/a).toLocaleString() + " KB";
678 673
     else
679  
-        result = Math.round((bytes/(1024*1024))*a)/a + " MB";
  674
+        result = (Math.round((bytes/(1024*1024))*a)/a).toLocaleString() + " MB";
680 675
 
681 676
     return negative ? "-" + result : result;
682 677
 }
6  extension/content/firebug/net/netReps.js
@@ -491,14 +491,14 @@ Firebug.NetMonitor.NetRequestEntry = domplate(Firebug.Rep, new Firebug.Listener(
491 491
             TD({"class": "netCol netProtocolCol a11yFocus", "role" : "gridcell"}),
492 492
             TD({"class": "netCol netDomainCol a11yFocus", "role" : "gridcell"}),
493 493
             TD({"class": "netTotalSizeCol netCol netSizeCol a11yFocus", "role": "gridcell"},
494  
-                DIV({"class": "netTotalSizeLabel netSummaryLabel"}, "0KB")
  494
+                DIV({"class": "netTotalSizeLabel netSummaryLabel"}, "0 B")
495 495
             ),
496 496
             TD({"class": "netTotalTimeCol netCol netTimeCol a11yFocus", "role":
497 497
                 "gridcell", colspan: "3"},
498 498
                 DIV({"class": "netSummaryBar", style: "width: 100%"},
499 499
                     DIV({"class": "netCacheSizeLabel netSummaryLabel", collapsed: "true"},
500 500
                         "(",
501  
-                        SPAN("0KB"),
  501
+                        SPAN("0 B"),
502 502
                         SPAN(" " + Locale.$STR("FromCache")),
503 503
                         ")"
504 504
                     ),
@@ -1965,7 +1965,7 @@ Firebug.NetMonitor.SizeInfoTip = domplate(Firebug.Rep,
1965 1965
 
1966 1966
     formatNumber: function(size)
1967 1967
     {
1968  
-        return size.size && size.size >= 1024 ? "(" + Str.formatNumber(size.size) + " B)" : "";
  1968
+        return size.size && size.size >= 1024 ? "(" + size.size.toLocaleString() + " B)" : "";
1969 1969
     },
1970 1970
 
1971 1971
     render: function(file, parentNode)

0 notes on commit ba6057b

Please sign in to comment.
Something went wrong with that request. Please try again.