leodido / moneylaundry

Collection of PHP utilities to filter and validate money with i18n in mind
MIT License
1 stars 0 forks source link

Symbols and currency codes #12

Open leogr opened 9 years ago

leogr commented 9 years ago

It seems that symbols are unrelated to the currency code setting. That makes heavy to implement the uncurrency filtering logic in lenient mode.

leodido commented 9 years ago

Please @leogr explain better what you mean.

leogr commented 9 years ago

As we have found out, when currency code is set to the formatter then currency symbol is not updated.

So some data have to be fetched from ResourceBundle directly as we are doing now.

This issue should be closed when we are sure that all data used is consistent with the current locale and currency code settings.

This should be a general constraint for all components. Do you agree?

leodido commented 9 years ago

Yes.

leogr commented 9 years ago

Currently all domain tests related to ResourceBundle are passing with ICU 51.

With ICU 54 some tests are not passing due to unknown locale inherit rule, an example is: http://demo.icu-project.org/icu-bin/locexp?d_=en&_=az_Cyrl&currency=THB

In this case, "az_Cyrl" inherit from root directly, instead of "az".

leogr commented 9 years ago

Now, currency symbol is ok and domain tests are passing. However, some parts of code are still using \NumberFormatter::CURRENCY_SYMBOL through the getSymbol method. Also POSITIVE_SUFFIX and NEGATIVE_PREFIX are built using \NumberFormatter::CURRENCY_SYMBOL.

So I suggest to find a way simplify the Uncurrency fallback logic and, if possibile, to remove the getSymbol method completely.

leogr commented 9 years ago

I think this issue is not resolved yet, because \NumberFormatter::CURRENCY_SYMBOL is still used.

See negative and positive prefixes extraction. Also here.