I am trying to create a set of classes to handle localization (mainly the currency part, but also the language).
I can imagine how logic can be, but I don’t know which names to use for different languages and currencies. I saw that for this there are many ISO standards that I have to choose?
In any case, the logic I was thinking about can help you with this:
I will have the Money class, indicating the quantity and currency. When creating an object, it receives the amount and currency (perhaps the object provided by the localization class?). You can add or multiply the amount. The add method takes a different monetary object as a parameter, and if it has a different currency, the conversion is automatic. Somewhere, the array is stored with all standard names, such as en_US and USD, matching them accordingly, and also tying them to the equivalent in US dollars as a scalar value. Money objects should be able to print amounts in different formats, for example, $ 1000 or U $ s, etc.
- Is this a good way to handle this?
- What basis should I stick to?
- Do you know any existing, unbound php libraries for this?
source
share