[CLOSED] [#494] Euroformat

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [#494] Euroformat

    Hi,

    Using Euroformat in my renderer it seems that te format for my country is wrong. It's displayed after the amount, but in several european countries we show the Euro sign before the amount :) ..

    (http://en.wikipedia.org/wiki/Linguis...rning_the_euro)

    Is there a way to change this in code ? Using LCID in the page directive didn't change the outcome


    Martin
    Last edited by Daniil; May 28, 2014 at 4:59 AM. Reason: [CLOSED]
  2. #2
    Hi Martin,

    You can override this:
    Ext.util.Format.euroMoney = function (v) {
        v = String(v).replace(/[^0-9.\-]/g, "");
        v = (Math.round((v - 0) * 100)) / 100;
        v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
        v = String(v);
    
        var ps = v.split('.'),
            whole = ps[0],
            sub = ps[1] ? ',' + ps[1] : ',00',
            r = /(\d+)(\d{3})/;
    
        while (r.test(whole)) {
            whole = whole.replace(r, '$1' + '.' + '$2');
        }
    
        return whole + sub + " €";
    };
  3. #3
    Will do... thanks !

    Is there a chance you can show the right format depending on the culture in the future ? Or must this be submitted to Sencha ?

    Martin
  4. #4
    Could you provide us with an override to some specific locale. Then I could add it to SVN.
  5. #5
    Quote Originally Posted by Daniil View Post
    Could you provide us with an override to some specific locale. Then I could add it to SVN.
    Ext.util.Format.euroMoney = function (v) {
                v = String(v).replace(/[^0-9.\-]/g, "");
                v = (Math.round((v - 0) * 100)) / 100;
                v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
                v = String(v);
    
    
                var ps = v.split('.'),
                    whole = ps[0],
                    sub = ps[1] ? ',' + ps[1] : ',00',
                    r = /(\d+)(\d{3})/;
    
    
                while (r.test(whole)) {
                    whole = whole.replace(r, '$1' + '.' + '$2');
                }
    
    
                return "€ " + whole + sub;
            };
    Netherlands, Austria, UK, Ireland, Malta, Cyprus, Latvia, Turkey, Scotland, Wales, Belgium :)
    Last edited by CarWise; May 26, 2014 at 9:37 AM.
  6. #6
    Ok, thanks. Created an Issue for that.
    https://github.com/extnet/Ext.NET/issues/494

    So, the only change is a euro sign position. I think it is worth to introduce a new boolean setting, like "euroPrefix".

    Ext.util.Format.euroMoney
    Ext.util.Format.euroMoney = function (v) {
        v = String(v).replace(/[^0-9.\-]/g, "");
        v = (Math.round((v - 0) * 100)) / 100;
        v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
        v = String(v);
    
        var ps = v.split('.'),
            whole = ps[0],
            sub = ps[1] ? ',' + ps[1] : ',00',
            r = /(\d+)(\d{3})/;
    
        while (r.test(whole)) {
            whole = whole.replace(r, '$1' + '.' + '$2');
        }
    
        v = whole + sub;
    
        if (!Ext.util.Format.euroPrefix) {
            v = v + " €";
        } else {
            v = "€ " +v;
        }
    
        return v;
    };
    The change has been committed to SVN trunk in the revision #5851.

    Then, if a euro sign should be prefixed, you can set up just
    Ext.util.Format.euroPrefix = true;
    Netherlands, Austria, UK, Ireland, Malta, Cyprus, Latvia, Turkey, Scotland, Wales, Belgium :)
    Just a half of these locales are supported by ExtJS. So, I would leave it all under a developer's responsibility. Please set
    Ext.util.Format.euroPrefix = true;
    if you need a euro sign to be prefixed.
  7. #7
    Yes, the only difference is the position. But I'm sure that my clients will complain about it haha...

    Thank you for your cooperation :)

    Martin
    Last edited by CarWise; May 26, 2014 at 12:08 PM.
  8. #8
    Looking closer into the wikipage it seems that in the UK (Scotland, Wales), Ireland and Malta there is no space between the sign and the amount. I'm not sure it's worth to look into that also..

    Martin
  9. #9
    I am not sure too:) What would you say?
  10. #10
    Quote Originally Posted by Daniil View Post
    I am not sure too:) What would you say?
    Well...it's no issue for me, but probably an issue for UK users of EXT.NET ... so you decide haha..
Page 1 of 2 12 LastLast

Posting Permissions