summaryrefslogtreecommitdiff
path: root/locale/hu/Num2text
blob: 8c619887f96a31190c13504f6528ad9e11763fff (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # Copyright (C) 2001
  4. #
  5. # Author: Dieter Simader
  6. # Email: dsimader@sql-ledger.org
  7. # Web: http://sourceforge.net/projects/ledger-smb/
  8. # Modified by: Medgyesi Aniko
  9. # **********************************
  10. # *#MEA1 * Hungarian version *
  11. # **********************************
  12. # Contributors:
  13. #
  14. # This program is free software; you can redistribute it and/or modify
  15. # it under the terms of the GNU General Public License as published by
  16. # the Free Software Foundation; either version 2 of the License, or
  17. # (at your option) any later version.
  18. #
  19. # This program is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. # You should have received a copy of the GNU General Public License
  24. # along with this program; if not, write to the Free Software
  25. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. #=====================================================================
  27. #
  28. # this is the default code for the Check package
  29. #
  30. #=====================================================================
  31. sub init {
  32. my $self = shift;
  33. #MEA1 English number ignored
  34. # %{ $self->{numbername} } =
  35. # (0 => 'Zero',
  36. # 1 => 'One',
  37. # 2 => 'Two',
  38. # 3 => 'Three',
  39. # 4 => 'Four',
  40. # 5 => 'Five',
  41. # 6 => 'Six',
  42. # 7 => 'Seven',
  43. # 8 => 'Eight',
  44. # 9 => 'Nine',
  45. # 10 => 'Ten',
  46. # 11 => 'Eleven',
  47. # 12 => 'Twelve',
  48. # 13 => 'Thirteen',
  49. # 14 => 'Fourteen',
  50. # 15 => 'Fifteen',
  51. # 16 => 'Sixteen',
  52. # 17 => 'Seventeen',
  53. # 18 => 'Eighteen',
  54. # 19 => 'Nineteen',
  55. # 20 => 'Twenty',
  56. # 30 => 'Thirty',
  57. # 40 => 'Forty',
  58. # 50 => 'Fifty',
  59. # 60 => 'Sixty',
  60. # 70 => 'Seventy',
  61. # 80 => 'Eighty',
  62. # 90 => 'Ninety',
  63. # 10**2 => 'Hundred',
  64. # 10**3 => 'Thousand',
  65. # 10**6 => 'Million',
  66. # 10**9 => 'Billion',
  67. # 10**12 => 'Trillion',
  68. # );
  69. #MEA1BEG Hungarian numbers
  70. %{ $self->{numbername} } =
  71. (0 => 'Nulla',
  72. 1 => 'egy',
  73. 2 => 'kettő',
  74. 3 => 'három',
  75. 4 => 'négy',
  76. 5 => 'öt',
  77. 6 => 'hat',
  78. 7 => 'hét',
  79. 8 => 'nyolc',
  80. 9 => 'kilenc',
  81. 10 => 'tíz',
  82. 11 => 'tizenegy',
  83. 12 => 'tizenkettő',
  84. 13 => 'tizenhárom',
  85. 14 => 'tizennégy',
  86. 15 => 'tizenöt',
  87. 16 => 'tizenhat',
  88. 17 => 'tizenhét',
  89. 18 => 'tizennyolc',
  90. 19 => 'tizenkilenc',
  91. 20 => 'húsz',
  92. 21 => 'huszonegy',
  93. 22 => 'huszonkettő',
  94. 23 => 'huszonhárom',
  95. 24 => 'huszonnégy',
  96. 25 => 'huszonöt',
  97. 26 => 'huszonhat',
  98. 27 => 'huszonhét',
  99. 28 => 'huszonnyolc',
  100. 29 => 'huszonkilenc',
  101. 30 => 'harminc',
  102. 40 => 'negyven',
  103. 50 => 'ötven',
  104. 60 => 'hatvan',
  105. 70 => 'hetven',
  106. 80 => 'nyolcvan',
  107. 90 => 'kilencven',
  108. 10**2 => 'száz',
  109. 10**3 => 'ezer',
  110. 10**6 => 'millió',
  111. 10**9 => 'milliárd',
  112. 10**12 => 'billió',
  113. );
  114. #MEA1END
  115. }
  116. sub num2text {
  117. my ($self, $amount) = @_;
  118. return $self->{numbername}{0} unless $amount;
  119. my @textnumber = ();
  120. # split amount into chunks of 3
  121. my @num = reverse split //, abs($amount);
  122. my @numblock = ();
  123. my @a;
  124. my $i;
  125. #MEA1BEG
  126. my $res;
  127. #MEA1END
  128. while (@num) {
  129. @a = ();
  130. for (1 .. 3) {
  131. push @a, shift @num;
  132. }
  133. push @numblock, join / /, reverse @a;
  134. }
  135. while (@numblock) {
  136. $i = $#numblock;
  137. @num = split //, $numblock[$i];
  138. if ($numblock[$i] == 0) {
  139. pop @numblock;
  140. next;
  141. }
  142. if ($numblock[$i] > 99) {
  143. push @textnumber, $self->{numbername}{$num[0]};
  144. # add hundred designation
  145. push @textnumber, $self->{numbername}{10**2};
  146. # reduce numblock
  147. $numblock[$i] -= $num[0] * 100;
  148. }
  149. $numblock[$i] *= 1;
  150. if ($numblock[$i] > 9) {
  151. # tens
  152. push @textnumber, $self->format_ten($numblock[$i]);
  153. } elsif ($numblock[$i] > 0) {
  154. # ones
  155. push @textnumber, $self->{numbername}{$numblock[$i]};
  156. }
  157. # add thousand, million
  158. if ($i) {
  159. #MEA1BEG above 2000 need hyphen between treegroups
  160. # if ($numblock[$i] > 9) {
  161. # push @textnumber, $self->format_ten($numblock[$i]);
  162. # } elsif ($numblock[$i] > 0) {
  163. # push @textnumber, $self->{numbername}{$numblock[$i]};
  164. # }
  165. if ($i==1 && $amount < 2000){
  166. $num = 10**($i * 3);
  167. push @textnumber, $self->{numbername}{$num};
  168. } else {
  169. $num = 10**($i * 3);
  170. push @textnumber, $self->{numbername}{$num}."-";
  171. }
  172. #MEA1END
  173. }
  174. pop @numblock;
  175. }
  176. #MEA1BEG First charachter is uppercase
  177. # join '', @textnumber;
  178. $res=ucfirst join '', @textnumber;
  179. #MEA1END
  180. #MEA1BEG remove last hyphen
  181. $res=~s/(\-)$//;
  182. return $res;
  183. #MEA1END
  184. }
  185. sub format_ten {
  186. my ($self, $amount) = @_;
  187. my $textnumber = "";
  188. my @num = split //, $amount;
  189. #MEA1BEG above 30 not above 20
  190. # if ($amount > 30) {
  191. if ($amount > 30) {
  192. #MEA1END
  193. $textnumber = $self->{numbername}{$num[0]*10};
  194. $amount = $num[1];
  195. } else {
  196. $textnumber = $self->{numbername}{$amount};
  197. $amount = 0;
  198. }
  199. $textnumber .= "".$self->{numbername}{$amount} if $amount;
  200. $textnumber;
  201. }
  202. 1;