GithubHelp home page GithubHelp logo

Comments (5)

wjcrowcroft avatar wjcrowcroft commented on May 20, 2024

Fair point - I'm from the UK as well, which is IMHO the only place in the world that does currency right.. I agree that a user shouldn't have to see EU-style formatting if they're used to standard formatting, or vice-versa..

Having said that, I think this is something that will be best handled by the parameters passed to the method (and in the next version, some form of configuration/settings object) - which leaves it squarely up to the developer. I'd say the job of the library is to provide a way of making that as easy as possible for them to present the correct number formatting for any given user.

It would definitely be an application-specific method of defining which locale to set, so I think this will be solved by the planned global settings configuration for the next version. Hope you can check it out when it's updated and let me know your thoughts!

Oh and thanks for the link, I'll take a look over it.

from accounting.js.

lukebarton avatar lukebarton commented on May 20, 2024

Currency is just a unit, just like weight, pressure, temperature, distance or density. The value (number) is seperate from that.

I agree about the parameter, a quick google suggests there is little you can garner from the client itself. Perhaps a global configuration overridable by a parameter would be the best approach.

from accounting.js.

wjcrowcroft avatar wjcrowcroft commented on May 20, 2024

Yeah, good call. Working on that now.

from accounting.js.

lukebarton avatar lukebarton commented on May 20, 2024

Damn comment & close button :)

from accounting.js.

wjcrowcroft avatar wjcrowcroft commented on May 20, 2024

Hey, I've just pushed v0.1.3 which adds a configurable settings object, which allows a developer to set the global localisation defaults under two objects, currency and number:

// Settings object that controls default parameters for library methods:
accounting.settings = {
    currency: {
        symbol : "$",   // default currency symbol is '$'
        format: "%s%v", // this controls string output: %s = symbol, %v = value/number
        decimal : ".",  // decimal point separator
        thousand: ",",  // thousands separator
        precision : 2   // decimal places
    },
    number: {
        precision : 0,  // default precision on numbers is 0
        thousand: ",",
        decimal : "."
    }
}

I'm leaving it up to individual developers and applications to decide which formatting to show the user, but I do have plans to build an optional plugin with default locale data for some common regions or countries... more on that later.

Until then I'd say this one's wrapped up, though there's more to do fo' sho'

Please re-open or make a new issue if you find bugs in the new code. Cheers!

from accounting.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.