-
Notifications
You must be signed in to change notification settings - Fork 802
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
[gnc-ui-utils.cpp] use icu::RBNF to convert numbers to long strings #1913
base: stable
Are you sure you want to change the base?
Conversation
b706509
to
16f1a80
Compare
Is there a use-case for this other than printing checks? Does anybody besides Americans write out the check's value in words as well as write the numerals? (Back in 1972 when my family went to England for 4 months my mom got a bank account there and wrote checks. I think they were pretty much like American ones, but that was more than 50 years ago.) When writing a check in the USA we write (using your shorter example) "Two thousand three hundred forty-five and 23/100". "Dollars" is pre-printed at the end of the line. |
aa70ef3
to
e86d4a9
Compare
rewritten in the much nicer boost::locale |
https://www.co-operativebank.co.uk/help-and-support/payments/cheques/ They advocate writing "only" irrespective of the amount... |
And also writing out "pounds", "and" and "pence", with the number of pence written out as words, rather different from the custom in the USA. How do you write the amount in Australia? Incidentally some in the US recommend when handwriting checks to draw a line from the fraction to the end if there's space, for example https://www.thebalancemoney.com/how-to-write-a-check-4019395, though only one of the half-dozen or so "how to write a check" sites I looked at did that, but all of them inserted "and" before the fraction. It seems we should create a US format string and make it translatable with instructions on the placeholders in a translator comment. |
d180161
to
b118339
Compare
b118339
to
f47c22d
Compare
@jralls see word substitution for check printing |
@christopherlam That's not localized, and what's the point of concocting a private formatting function? Use There's a much better formatting and I/O library, |
I didn't use boost format because it requires that all format variables are used. And I felt it would be better to have more flexibility, allowing eg integer words, integer numbers, fraction words, fraction numbers as options. |
OK, but that doesn't do any good unless you mark the string for translation and document the construction thoroughly for translators with a translator comment. Not only can most translators not understand code, they can't even see it in Weblate without significant effort. |
The format string would be best IMHO be a global preference rather than a translatable string. I figure most users would prefer being able to fine tune rather than rely on random translators. I felt this branch would be a temporary until we plug into the preference mechanism. |
OK, that might be true at least for some users. Temporary tends to stay for a long time around here so at least comment it thoroughly including a FIXME or TODO about creating a preference. It does occur to me that @cstim commented about the untranslatability 17 years ago and there are no bugs about it so maybe only English speakers (maybe even only Americans) use the check printing and there's no actual point to localizing it. Maybe you should add one as an enhancement request to create another reminder to add the preference. |
Yes, I would claim this isn't used in any other country anyway. Hence you can quite safely ignore the translatability here. |
Hmm, it kind of follows that localizing the number-strings doesn't make sense either and it should be just left alone. |
@christopherlam Do you still want to pursue this? |
This branch aims to use ICU instead of hand rolling the number->string routine... It could be limited to English words and two decimal places only if you like |
The problem is that we have a particular use for that conversion and the ICU wording doesn't fit it. |
result:
Number 123456789.010000 in words: one hundred twenty-three million four hundred fifty-six thousand seven hundred eighty-nine point zero one
Number 12.000000 in words: 十二
Number 123456789.010000 in words: 一億二千三百四十五万六千七百八十九・〇一
Number 2345.23 in words: deux mille trois cent quarante-cinq virgule deux trois
Number 2345.23 in words: 二千三百四十五・二三