Comments (8)
Do we need to do something for other languages? E.g. in french, we use a comma (spelled 'virgule') instead of a dot.
from numbers_and_words.
well for example in hungarian i believe you have to explicitly include the capacity for the fraction part, e.g. 21.7 is something like 'twenty-one point and seven tenth', but i have to research the hungarian grammar rules further
from numbers_and_words.
It's a temporary solution. Of course need to refactoring. Float#to_words is not language dependent function, so first of all, language words should be in appropriate places and I think there are many language-specific subtasks. Maybe @sorich87, @eLod you could get this task and try to create a good solution for appropriate language French, Hungarian as in English and Russian the approach is quite simple.
from numbers_and_words.
i created a topic branch for this issue so we can speak more easily about it (compare). this is only a proof-of-concept so i can verify my ideas. @dblock any thoughts about the english translations?
from numbers_and_words.
I think in english digits after the 'point' are spelled one by one, or you use 'and' instead of 'point' and you pluralize the 'micro' part.
E.g. 21.77 = 'twenty-one point seven seven' or 'twenty-one AND seventy-seven hundredthS'.
from numbers_and_words.
well i'm not terrible familiar with precise english grammar, also i'm not sure if this is a common idiom. in hungarian we only have the 'proper' form which includes the fraction 'magnitude' (e.g. 'hundredths') - also the missing pluralization of this magnitude is simply an overlook on my part (we don't pluralize them in hungarian). the second from (the '... point seven seven') i believe we have in spoken language but i don't think it's a proper way (as per the hungarian grammar rules). so i think based on how common this second form is (e.g. how about french, spanish or italian?) it can be implemented in a separate strategy (which can be included in given languages) or in base.
also i've tried not to touch the API, so the way i'm handling the integer and fractional parts may need some refactor. also i moved the float (and integer) extension to numeric. what i recently recognized is that we will have problems with large floats, e.g. ((42 ** 42) + 0.1).to_s
would return scientific notation for which our conversion will fail (not sure how we could convert this to decimal form, maybe with sprintf
?).
from numbers_and_words.
If you make the fraction magnitude part optional, it will cover french and spanish (and I guess other latin languages as well).
IMO, this library shouldn't cover scientific notation. Whoever need to handle it could do the rounding themselves and chose which rounding method is more appropriate to their use case.
from numbers_and_words.
1, you mean in french, spanish and other latin languages they don't include the 'magnitude' by default? or all of them have this 'terse' format (remember, 'zero point seven seven' not just does not include the 'magnitude', it also has the fractional part spelled otherwise, e.g. 'seven seven' instead of 'seventy-seven')? do any of them have the 'proper' format?
2, i did not mean to say that this gem should support scientific notation. my problem is that (42 ** 42) + 0.1
is a float, so right now neither do we raise any errors (although we have a validation hook), nor do we return the correct answer (we cast everything - but the "." - to_i
, so "1.50130937545297e+68" will be converted as "1.501309375452970068"). i only wanted to be sure to handle this situation (either by raising an error or returning the correct answer).
from numbers_and_words.
Related Issues (20)
- Fork? HOT 12
- Finish German support
- Numeric Fallback HOT 5
- Wrong dependencies management makes the gem require activesupport 5.0 thus Ruby 2.2.2 HOT 8
- Drop EOL'ed Rubies in Travis CI HOT 1
- Configure I18n.available_locales
- Support for Arabic HOT 3
- Crashing Spanish Translations HOT 2
- Support for Chinese? HOT 1
- Support for float numbers in french HOT 1
- Floating-point numbers with five or more digits after decimal separator
- Move this gem into a github org?
- Ability to add units
- Why included .yml languages as internal instead of document them and let user customize? HOT 2
- Wrong precision 2 for spanish HOT 1
- I18n::InvalidPluralizationData (translation data {:one=>"tenth", :other=>"tenths"} HOT 7
- Incorrect joiner for some Dutch examples HOT 3
- Problem with hundreds as array HOT 1
- Does this gem work with Ruby 3.2.0 ? HOT 1
- When the numbers start with 0 it showing incorrect string value. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numbers_and_words.