Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/checkprinting/numbertowords.cpp
Show All 20 Lines | |||||
21 | #include "numbertowords.h" | 21 | #include "numbertowords.h" | ||
22 | 22 | | |||
23 | // KDE includes | 23 | // KDE includes | ||
24 | #include <KLocalizedString> | 24 | #include <KLocalizedString> | ||
25 | 25 | | |||
26 | MyMoneyMoneyToWordsConverter::MyMoneyMoneyToWordsConverter() | 26 | MyMoneyMoneyToWordsConverter::MyMoneyMoneyToWordsConverter() | ||
27 | { | 27 | { | ||
28 | // Single-digit and small number names | 28 | // Single-digit and small number names | ||
29 | m_smallNumbers << i18nc("@item the number 0", "zero") << i18nc("@item the number 1", "one") << i18nc("@item the number 2", "two") << i18nc("@item the number 3", "three") << i18nc("@item the number 4", "four") << i18nc("@item the number 5", "five") << i18nc("@item the number 6", "six") << i18nc("@item the number 7", "seven") << i18nc("@item the number 8", "eight") << i18nc("@item the number 9", "nine") << i18nc("@item the number 10", "ten") << i18nc("@item the number 11", "eleven") << i18nc("@item the number 12", "twelve") << i18nc("@item the number 13", "thirteen") << i18nc("@item the number 14", "fourteen") << i18nc("@item the number 15", "fifteen") << i18nc("@item the number 16", "sixteen") << i18nc("@item the number 17", "seventeen") << i18nc("@item the number 18", "eighteen") << i18nc("@item the number 19", "nineteen"); | 29 | m_smallNumbers << i18nc("@item the number 0", "Zero") << i18nc("@item the number 1", "One") << i18nc("@item the number 2", "Two") << i18nc("@item the number 3", "Three") << i18nc("@item the number 4", "Four") << i18nc("@item the number 5", "Five") << i18nc("@item the number 6", "Six") << i18nc("@item the number 7", "Seven") << i18nc("@item the number 8", "Eight") << i18nc("@item the number 9", "Nine") << i18nc("@item the number 10", "Ten") << i18nc("@item the number 11", "Eleven") << i18nc("@item the number 12", "Twelve") << i18nc("@item the number 13", "Thirteen") << i18nc("@item the number 14", "Fourteen") << i18nc("@item the number 15", "Fifteen") << i18nc("@item the number 16", "Sixteen") << i18nc("@item the number 17", "Seventeen") << i18nc("@item the number 18", "Eighteen") << i18nc("@item the number 19", "Nineteen"); | ||
30 | 30 | | |||
31 | // Tens number names from twenty upwards | 31 | // Tens number names from twenty upwards | ||
32 | m_tens << "" << "" << i18nc("@item the number 20", "twenty") << i18nc("@item the number 30", "thirty") << i18nc("@item the number 40", "forty") << i18nc("@item the number 50", "fifty") << i18nc("@item the number 60", "sixty") << i18nc("@item the number 70", "seventy") << i18nc("@item the number 80", "eighty") << i18nc("@item the number 90", "ninety"); | 32 | m_tens << "" << "" << i18nc("@item the number 20", "Twenty") << i18nc("@item the number 30", "Thirty") << i18nc("@item the number 40", "Forty") << i18nc("@item the number 50", "Fifty") << i18nc("@item the number 60", "Sixty") << i18nc("@item the number 70", "Seventy") << i18nc("@item the number 80", "Eighty") << i18nc("@item the number 90", "Ninety"); | ||
33 | 33 | | |||
34 | // Scale number names for use during recombination | 34 | // Scale number names for use during recombination | ||
35 | m_scaleNumbers << "" << i18nc("@item the number 1000", "thousand") << i18nc("@item the number 1,000,000", "million") << i18nc("@item the number 1,000,000,000", "billion"); | 35 | m_scaleNumbers << "" << i18nc("@item the number 1000", "Thousand") << i18nc("@item the number 1,000,000", "Million") << i18nc("@item the number 1,000,000,000", "Billion"); | ||
36 | } | 36 | } | ||
37 | 37 | | |||
38 | // Converts a three-digit group into English words | 38 | // Converts a three-digit group into English words | ||
39 | QString MyMoneyMoneyToWordsConverter::convertTreeDigitGroup(int threeDigitNumber) | 39 | QString MyMoneyMoneyToWordsConverter::convertTreeDigitGroup(int threeDigitNumber) | ||
40 | { | 40 | { | ||
41 | // Initialise the return text | 41 | // Initialise the return text | ||
42 | QString groupText; | 42 | QString groupText; | ||
43 | 43 | | |||
44 | // Determine the hundreds and the remainder | 44 | // Determine the hundreds and the remainder | ||
45 | int hundreds = threeDigitNumber / 100; | 45 | int hundreds = threeDigitNumber / 100; | ||
46 | int tensUnits = threeDigitNumber % 100; | 46 | int tensUnits = threeDigitNumber % 100; | ||
47 | 47 | | |||
48 | // Hundreds rules | 48 | // Hundreds rules | ||
49 | if (hundreds != 0) { | 49 | if (hundreds != 0) { | ||
50 | groupText += m_smallNumbers[hundreds] + i18nc("@item This comes after the hundred value digit", " hundred"); | 50 | groupText += m_smallNumbers[hundreds] + i18nc("@item This comes after the hundred value digit", " Hundred"); | ||
51 | 51 | | |||
52 | if (tensUnits != 0) | 52 | if (tensUnits != 0) | ||
53 | groupText += i18nc("@item This comes after the hunder text if the tens unit is different from 0", " and "); | 53 | groupText += i18nc("@item This comes after the hunder text if the tens unit is different from 0", " and "); | ||
54 | } | 54 | } | ||
55 | 55 | | |||
56 | // Determine the tens and units | 56 | // Determine the tens and units | ||
57 | int tens = tensUnits / 10; | 57 | int tens = tensUnits / 10; | ||
58 | int units = tensUnits % 10; | 58 | int units = tensUnits % 10; | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 105 | if (digitGroups[i] != 0) { | |||
115 | combined = prefix + combined; | 115 | combined = prefix + combined; | ||
116 | } | 116 | } | ||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | if (fraction != 0) | 119 | if (fraction != 0) | ||
120 | return i18nc("@label The first argument is the amount in words, the second is the fractional part and the third is the denominator of the fractional part", | 120 | return i18nc("@label The first argument is the amount in words, the second is the fractional part and the third is the denominator of the fractional part", | ||
121 | "%1 and %2/%3", combined, fraction, denom); | 121 | "%1 and %2/%3", combined, fraction, denom); | ||
122 | else | 122 | else | ||
123 | return combined; | 123 | return i18nc("@label The first argument is the amount in words, the second is the fractional part and the third is the denominator of the fractional part", | ||
124 | "%1 and %2/%3", combined, "No", denom); | ||||
124 | } | 125 | } |