
On 5/9/2016 6:53 PM, Aline Manera wrote:
On 05/05/2016 04:02 AM, pkulkark@linux.vnet.ibm.com wrote:
From: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com>
co-authored by: Archana Singh <archus@linux.vnet.ibm.com>
This patch modifies the wok.formatMeasurement util to include formatting based on locale passed, in wok.utils.js
Signed-off-by: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com> --- ui/js/src/wok.utils.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js index 214749a..d198c37 100644 --- a/ui/js/src/wok.utils.js +++ b/ui/js/src/wok.utils.js @@ -140,6 +140,8 @@ wok.changetoProperUnit = function(numOrg, digits, base) { return new Formatted(number, unit); }
+ var n_locale = settings['locale'] || null; + var fixed = settings['fixed'];
var unitMapping = unitBaseMapping[base]; @@ -153,11 +155,13 @@ wok.changetoProperUnit = function(numOrg, digits, base) {
var formatted = number / startingValue; formatted = fixed ? formatted.toFixed(fixed) : formatted; - + formatted = n_locale ? Number(formatted).toLocaleString(n_locale) : Number(formatted).toLocaleString() return new Formatted(formatted, suffix + unit); } - - return new Formatted(fixed ? number.toFixed(fixed) : number, unit); + var formatted = 0; + formatted = fixed ? formatted.toFixed(fixed) : formatted; + formatted = n_locale ? Number(formatted).toLocaleString(n_locale) : Number(formatted).toLocaleString() + return new Formatted(formatted, unit);
It is confusing to me with too many variables named 'formatted'
+ formatted = fixed ? number.toFixed(fixed) : number; + /* this will format the number as per locale. */ + formatted_locale = n_locale ? Number(formatted).toLocaleString(n_locale) : Number(formatted).toLocaleString() + return new Formatted(formatted_locale, unit); Do it make sense now?
};
wok.formatMeasurement = format;
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel