我试图开设一套处理本地化问题的班级(主要是货币部分,但也包括语言)。
我可以想象这一逻辑如何,但我不知道用什么名称来使用不同的语言和货币。 我已经看到这方面的许多标准化组织标准?
在这里,如果你也能够帮助,那么我所想的逻辑就是:
I would have a Money class, with amount and currency attributes. On creation, the object receives the amount and the currency (an object provided by the localization class maybe?). You can add to or multiply the amount. The add method takes another money object as parameter, and if it has a different currency, a convertion is made automatically. Somewhere an array is stored with all the standard names such as en_US and USD, relating them appropiately, and also relating them to the equivalent in USD as a scalar value. Money objects should be able to print the amounts in different formats, such as $ 1000, or U$s, etc.
- Is this a good way to deal with this?
- Which standar should I follow?
- Do you know any already existent, decoupled php libraries to do this?