Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Italian support #94

Open
aldesantis opened this issue Feb 3, 2014 · 6 comments
Open

Improve Italian support #94

aldesantis opened this issue Feb 3, 2014 · 6 comments

Comments

@aldesantis
Copy link

numbers_and_words currently has poor support for Italian. I have the code needed to convert a number into Italian, but I'm not able to integrate it in your gem.

If I provide the code, can someone with a better understanding of numbers_and_words use it to improve the present implementation?

Thanks in advance.

@aldesantis
Copy link
Author

@kslazarev: any info about this? Do you think you'd be able to do it?

@dblock
Copy link
Collaborator

dblock commented Feb 15, 2014

@alessandro1997 I am not sure what you're asking for. Make code changes and pull requests, please.

@aldesantis
Copy link
Author

Never mind. First of all, how would I go about removing the spaces between translations? 170 in Italian is "centosettanta", not "cento settanta". Spaces are added after millions and billions (e.g. 1,740,794 is "un milione settecentoquarantamilasettecentonovantaquattro").

Also, 1,000 is "mille", not "uno mille".

If you could point me in the right direction I'd be glad to make the needed changes.

@eLod
Copy link
Collaborator

eLod commented Feb 16, 2014

@alessandro1997 you could do this on a couple 'level'

the most basic is you provide some kind of failing tests, for example you could edit the https://github.com/kslazarev/numbers_and_words/blob/development/spec/numbers_and_words/integer/fixture_examples/it.yml (please note: you should work off of the development branch) so it would be clear what the problems are, however without further instructions (and without knowledge about the italian language) i'm not sure anyone could take on them

you could also provide some instructions like you did. for example for the problem with where to put spaces you could check https://github.com/kslazarev/numbers_and_words/blob/development/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb (see also https://github.com/kslazarev/numbers_and_words/blob/development/lib/numbers_and_words/strategies/figures_converter/languages/base.rb how it is used), in a nutshell (when you call I18n.with_locale(:it) { 1740794.to_words }) what is happening is:

  • strings_logic is called with capacity_count = 2 (figures are [4, 9, 7, 0, 4, 7, 1]), which calls number_without_capacity_to_words (which is an alias words_in_capacity, which in turn calls strings_logic with figures changed) and complex_number_to_words (which - simply put - iterates on grouped figures and pushes the mega word if needed) so:
  • strings_logic is called with capacity_count = nil (figures are [4, 9, 7]), and the array ["novantaquattro", "7 cento"] is returned (via calling hundreds_number_to_words)
  • strings_logic is called with capacity_count = nil (figures are [0, 4, 7]), and the array ["novantaquattro", "7 cento"] is returned (via calling hundreds_number_to_words)
  • strings_logic is called with capacity_count = nil (figures are [1]), and the array ["uno"] is returned (via calling simple_number_to_words)
  • an array of ["novantaquattro", "7 cento", "mille", "quaranta", "7 cento", "milione", "uno"] is returned from the 'outer' strings_logic call, this is reversed and joined

you can check how modifications are made to this process on every level, e.g.:

depending on the rules of the italian language i would change https://github.com/kslazarev/numbers_and_words/blob/development/lib/numbers_and_words/strategies/figures_converter/languages/it.rb to alter strings_logic and/or hundreds_number_to_words

@davidebaldini
Copy link

@eLod, if you need feedback, I'm Italian; any example reported by alessandro1997 is correct.

@eLod
Copy link
Collaborator

eLod commented Nov 10, 2015

@davidebaldini i'm not working on this, i was just trying to help @alessandro1997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants