Open aldesantis opened 10 years ago
@kslazarev: any info about this? Do you think you'd be able to do it?
@alessandro1997 I am not sure what you're asking for. Make code changes and pull requests, please.
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.
@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
)["novantaquattro", "7 cento", "mille", "quaranta", "7 cento", "milione", "uno"]
is returned from the 'outer' strings_logic
call, this is reversed and joinedyou 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
@eLod, if you need feedback, I'm Italian; any example reported by alessandro1997 is correct.
@davidebaldini i'm not working on this, i was just trying to help @alessandro1997
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.