carlosantoniodasilva / i18n_alchemy

I18n date/number parsing/localization - RMU Project
http://mendicantuniversity.org/
MIT License
159 stars 34 forks source link

Issue with parser with the letters "e" and "d" #47

Open RaphaelAudet opened 6 years ago

RaphaelAudet commented 6 years ago

Hi, I have tried using the parser on a lot of data and have found a issue with a very specific case of the parser.

description of issue

When using the localized method with french locale if the decimal is followed by the letters "e" or "d" (with or without spaces) the localization method produces 0, most other non-numeric I have tried work.

steps to reproduce

see code below

irb(main):105:0> I18n.with_locale(:fr) { quote.localized({quantity1_price_en: "0,29"}) }.quantity1_price_en
=> "0.290"
irb(main):106:0> I18n.with_locale(:fr) { quote.localized({quantity1_price_en: "0,28889"}) }.quantity1_price_en
=> "0.289"
irb(main):107:0> I18n.with_locale(:fr) { quote.localized({quantity1_price_en: "0,28889 per unit"}) }.quantity1_price_en
=> "0.289"
irb(main):108:0> I18n.with_locale(:fr) { quote.localized({quantity1_price_en: "0,28889 euros per unit"}) }.quantity1_price_en
=> "0.000"
irb(main):109:0> I18n.with_locale(:fr) { quote.localized({quantity1_price_en: "0,28889 dollars per unit"}) }.quantity1_price_en
=> "0.000"

Parsing the strings "0,29", "0,29 per unit", "0,29 oioioioio" all produce "0,29" which is fine The string "0,28889 euros per unit" produce "0.000" which is unexpected

what is expected I'd expect

I would expect parsing the string "0,28889 euros per unit" produce "0.28889"

ps: there is also a rounding issue but we should perhaps leave this out of this issue

sobrinho commented 5 years ago

@carlosantoniodasilva can be closed with #48 being merged.