Newsgroup: it.comp.lang.delphi
Titolo: help with lettere numero 2 text

Dear users,
I am Daniel and I am from Poland. I don't speak Italian... please
forgive me.
But I am writing because I have a problem. I write small application
in Delphi, for a small company which cooperate with an Italian
company.... and I have to convert numbers into text. For example:
60=> sesanta euro .... and this conversion must be made in Italian
Language.
The problem is... I don't speak Italian at all ;-( I have created my
own function in Polish language but in Italian I feel powerless.... I
try to search google, but it's not so easy to do it in Italian
language. For example I tried: "Numero 2 Lettere Delphi" but with no
results ;-(
Please give me some tips. Maybe there is a link to a Delphi function
with it.  Maybe you know a link with a function in Delphi which
convert numbers into text in Italian language?
Do you know any links?
Please help,
Regards,

 
Caro Daniel,
this page probably will help you
http://www.locuta.com/num.html
Massimo

 Language.
[..]
bye
Valter
http://groups.google.it/group/it.comp.lang.delphi/browse_thread/thread/fef2c2f8d1b6d5db/5fd695d7f75fe863?lnk=st&q=cifre+lettere+group:it.comp.lang.delphi+author:jax&rnum=1&hl=it#5fd695d7f75fe863
function TraduciNumeroInStringa(sNumero: String; bTraduciDecimali: Boolean):
String;
var
 ABC4_ABC3_ABC2_ABC1, sDecimali: String;
 ABC1, ABC2, ABC3, ABC4: String;
 iVirgola: SmallInt;
 function TrasformaGruppo(ABC: String): String;
 const
  Cifre: array [0..9] of String =
    ('', 'uno', 'due', 'tre', 'quattro', 'cinque',
     'sei', 'sette', 'otto', 'nove');
  DecUni10: array [1..9] of String =
    ('undici', 'dodici', 'tredici', 'quattordici',
     'quindici', 'sedici', 'diciassette',
     'diciotto', 'diciannove');
  Decine: array [1..9] of String =
    ('dieci', 'venti', 'trenta', 'quaranta', 'cinquanta',
     'sessanta', 'settanta', 'ottanta', 'novanta');
 var
  iA: Integer;
  iB: Integer;
  iC: Integer;
  iBC: Integer;
 begin
  iA := StrToInt(Copy(ABC, 1, 1));
  iB := StrToInt(Copy(ABC, 2, 1));
  iC := StrToInt(Copy(ABC, 3, 1));
  iBC := StrToInt(Copy(ABC, 2, 2));
  if (iA = 1) then
   Result := 'cento'
  else
  if (iA <> 0) then
   Result := Cifre[iA] + 'cento';
  if (iBC > 10) and (iBC < 20) then
   Result := Result + DecUni10[iBC-10]
  else
  begin
   if iB <> 0 then
   begin
    Result := Result + Decine[iB];
    if iC in [1, 8] then
     Delete(Result, Length(Result), 1);
   end;
   if iC <> 0 then
    Result := Result + Cifre[iC];
  end;
 end;
begin
 iVirgola := Pos(',', sNumero);
 if iVirgola <= 0 then
  ABC4_ABC3_ABC2_ABC1 := sNumero
 else
 begin
  ABC4_ABC3_ABC2_ABC1 := Copy(sNumero, 1, iVirgola - 1);
  sDecimali := Copy(sNumero, iVirgola + 1, Length(sNumero) - iVirgola);
  if bTraduciDecimali then
   sDecimali := Copy(StringOfChar('0', 3), 1, 3-Length(sDecimali)) +
sDecimali;
 end;
 ABC4_ABC3_ABC2_ABC1 := Copy(StringOfChar('0', 12),
               1,
               12-Length(ABC4_ABC3_ABC2_ABC1)) +
             ABC4_ABC3_ABC2_ABC1;
 ABC1 := Copy(ABC4_ABC3_ABC2_ABC1, 10, 3);
 ABC2 := Copy(ABC4_ABC3_ABC2_ABC1,  7, 3);
 ABC3 := Copy(ABC4_ABC3_ABC2_ABC1,  4, 3);
 ABC4 := Copy(ABC4_ABC3_ABC2_ABC1,  1, 3);
 ABC4 := TrasformaGruppo(ABC4);
 if ABC4 <> '' then
 begin
  if ABC4 = 'uno' then
   Result := 'unmiliardo'
  else
   Result := ABC4 + 'miliardi';
 end;
 ABC3 := TrasformaGruppo(ABC3);
 if ABC3 <> '' then
 begin
  if ABC3 = 'uno' then
   Result := 'unmilione'
  else
   Result := Result + ABC3 + 'milioni';
 end;
 ABC2 := TrasformaGruppo(ABC2);
 if ABC2 <> '' then
 begin
  if ABC2 = 'uno' then
   Result := 'mille'
  else
   Result := Result + ABC2 + 'mila';
 end;
 Result := Result + TrasformaGruppo(ABC1);
 if Result = '' then Result := 'zero';
 if sDecimali <> '' then
  if bTraduciDecimali then
   Result := Result + '/' + TrasformaGruppo(sDecimali)
  else
   Result := Result + '/' + sDecimali;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(TraduciNumeroInStringa('5000,50', true));
end;