[Kimchi-devel] [Wok][PATCH v2 6/7] Multi-Culture support : Modify wok.formatMeasurement util to include formatting based on locale

Aline Manera alinefm at linux.vnet.ibm.com
Tue May 10 13:44:45 UTC 2016



On 05/10/2016 04:05 AM, Archana Singh wrote:
>
>
> On 5/9/2016 6:53 PM, Aline Manera wrote:
>>
>>
>> On 05/05/2016 04:02 AM, pkulkark at linux.vnet.ibm.com wrote:
>>> From: Pooja Kulkarni <pkulkark at linux.vnet.ibm.com>
>>>
>>> co-authored by: Archana Singh <archus at 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 at 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?
>

Yeap! =)

Thanks for that!

>>
>>
>>>       };
>>>
>>>       wok.formatMeasurement = format;
>>
>> _______________________________________________
>> Kimchi-devel mailing list
>> Kimchi-devel at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>
>




More information about the Kimchi-devel mailing list