This is a migrated thread and some comments may be shown as answers.

USD formatted for user in de-DE (and Euro formatted for user in en-US)

4 Answers 125 Views
Globalization
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 28 Apr 2015, 10:12 PM

Our app is fully localized/globalized, supporting (some of the few) en-US and de-DE.

In our DB, some of the currency values are stored in USD, some of the currency values are stored as Euros. Obviously, we want to keep the currency straight between the two - formatting as USD, when in fact it is Euros, would be a big mistake.

So, following this example, we can format for USD/Euros, given the proper locale.

My issue is: Given data (12345.67) in the DB in Euros and the user logged into the en-US locale, I want to have the Euro symbol show up properly (including location of symbol relative to numeric value) and the commas/decimals to be proper as well (i.e. 12,345.67 €). And the reverse, given data (98765.43) in the DB in USD and the user logged into de-DE, I want to have the USD symbol show up and the commas/decimals to be proper as well (i.e. $ 98.765,43).

How can I achieve this?

Thanks,

--Ed

 

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Apr 2015, 04:02 PM
Hello,

I am not sure if I understand how exactly are the values displayed but you could use the kendo.toString method to format the values based on specific culture(live demo) instead of the current kendo culture. If this does not work for your scenario then please provide more detailed information on how are the values displayed.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ed
Top achievements
Rank 1
answered on 01 May 2015, 03:23 PM

Hi Daniel,

Unfortunately, I cannot view any DOJO's because of our firewall restrictions. I will try to rephrase my issue and hope we are on the same page.

What we want is for the numeric value to be formatted using the current user's specific culture (works great with "n2"). What I want in addition to that is to format the currency from a different culture. The currency of the numeric value in the DB remains constant, but the end user may change cultures.

For example, the numeric value in the DB could be 12345.67 and with a currency of USD.

When a user selects en-US culture, it should be formatted as $12,345.67

When a user selects de-DE culture, it should be formatted as $12.345,67

Does that make sense?

--Ed

0
Ed
Top achievements
Rank 1
answered on 01 May 2015, 03:28 PM

To add a bit, what I need is a way to specify the user's selected culture and the culture of the numeric value.

So, to format currency, we would need to specify two cultures: one for the formatting of the numeric value and one to specify the currency symbol

kendo.culture("de-DE");
kendo.currencyCulture("en-US");
kendo.toString(1234.567, "c3"); // $1.234,567

and in inverse (if numeric value is in Euros and user's culture is en-US)

kendo.culture("en-US");
kendo.currencyCulture("de-DE");
kendo.toString(1234.567, "c3"); // 1,234.567 €

0
Daniel
Telerik team
answered on 05 May 2015, 08:52 AM
Hello again Ed,

I believe we are on the same page - format numbers based on the current culture and currency values based on specific culture. Instead of a currencyCulture method you should pass the culture to the toString method when formatting currency values:
kendo.culture("en-US");
kendo.toString(1234.567, "c3", "de-DE");
I attached the sample from my previous reply to the thread. 

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Globalization
Asked by
Ed
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ed
Top achievements
Rank 1
Share this question
or