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

5 posts, 0 answers
  1. Ed
    Ed avatar
    168 posts
    Member since:
    Sep 2013

    Posted 28 Apr 2015 Link to this post

    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

     

  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 30 Apr 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Ed
    Ed avatar
    168 posts
    Member since:
    Sep 2013

    Posted 01 May 2015 in reply to Daniel Link to this post

    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

  5. Ed
    Ed avatar
    168 posts
    Member since:
    Sep 2013

    Posted 01 May 2015 in reply to Ed Link to this post

    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 €

  6. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 05 May 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready