Форум: "Основная";
Текущий архив: 2004.04.25;
Скачать: [xml.tar.bz2];
Внизесть ли кого модуль для перевода текста на транслит? Найти похожие ветки
← →
Denis_Visma (2004-04-09 17:32) [0]сабж
← →
Yanis © (2004-04-09 17:35) [1]
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
translit: TRadioButton;
perevod: TRadioButton;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
Eng : String ="!@#$%^&*()_+|QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?1234567890-=\qwertyuiop[]asdfghjkl;""zxcvbnm,./!"№;%:?*()_+/ЙЦУКЕНГШЩЗХЪ ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,1234567890-=\йцукенгшщзхъфывапролджэячсмитьбю.";
Rus : String ="!"№;%:?*()_+/ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,1234567890-=\йцукенгшщзхъфывапролджэячсмитьбю.!@#$%^&*()_+|QWERTYUIOP{}A SDFGHJKL:"ZXCVBNM<>?1234567890-=\qwertyuiop[]asdfghjkl;""zxcvbnm,./";
implementation
function Translit_(s: string): string;
var
i: integer;
t: string;
begin
for i:=1 to Length(s) do
begin
case s[i] of
"а": t:=t+"a";
"б": t:=t+"b";
"в": t:=t+"v";
"г": t:=t+"g";
"д": t:=t+"d";
"е": t:=t+"e";
"ё": t:=t+"ye";
"ж": t:=t+"zh";
"з": t:=t+"z";
"и": t:=t+"i";
"й": t:=t+"y";
"к": t:=t+"k";
"л": t:=t+"l";
"м": t:=t+"m";
"н": t:=t+"n";
"о": t:=t+"o";
"п": t:=t+"p";
"р": t:=t+"r";
"с": t:=t+"s";
"т": t:=t+"t";
"у": t:=t+"u";
"ф": t:=t+"f";
"х": t:=t+"ch";
"ц": t:=t+"z";
"ч": t:=t+"ch";
"ш": t:=t+"sh";
"щ": t:=t+"ch";
"ъ": t:=t+"""";
"ы": t:=t+"y";
"ь": t:=t+"""";
"э": t:=t+"e";
"ю": t:=t+"yu";
"я": t:=t+"ya";
"А": T:=T+"A";
"Б": T:=T+"B";
"В": T:=T+"V";
"Г": T:=T+"G";
"Д": T:=T+"D";
"Е": T:=T+"E";
"Ё": T:=T+"YE";
"Ж": T:=T+"ZH";
"З": T:=T+"Z";
"И": T:=T+"I";
"Й": T:=T+"Y";
"К": T:=T+"K";
"Л": T:=T+"L";
"М": T:=T+"M";
"Н": T:=T+"N";
"О": T:=T+"O";
"П": T:=T+"P";
"Р": T:=T+"R";
"С": T:=T+"S";
"Т": T:=T+"T";
"У": T:=T+"U";
"Ф": T:=T+"F";
"Х": T:=T+"CH";
"Ц": T:=T+"Z";
"Ч": T:=T+"CH";
"Ш": T:=T+"SH";
"Щ": T:=T+"CH";
"Ъ": T:=T+"""";
"Ы": T:=T+"Y";
"Ь": T:=T+"""";
"Э": T:=T+"E";
"Ю": T:=T+"YU";
"Я": T:=T+"YA";
"a": t:=t+"а";
"b": t:=t+"б";
"v": t:=t+"в";
"g": t:=t+"г";
"d": t:=t+"д";
"e": t:=t+"е";
{"ye": t:=t+"ye";
"zh": t:=t+"zh"; }
"z": t:=t+"з";
"i": t:=t+"и";
"y": t:=t+"у";
"k": t:=t+"к";
"l": t:=t+"л";
"m": t:=t+"м";
"n": t:=t+"н";
"o": t:=t+"о";
"p": t:=t+"п";
"r": t:=t+"р";
"s": t:=t+"с";
"t": t:=t+"т";
"u": t:=t+"у";
"f": t:=t+"ф";
//"х": t:=t+"ch";
//"z": t:=t+"ц";
{"ч": t:=t+"ch";
"ш": t:=t+"sh";
"щ": t:=t+"ch";
"ъ": t:=t+"""";
"ь": t:=t+"""";
"ы": t:=t+"y";}
"c": T:=T+"ц";
//"e": t:=t+"е";
{"ю": t:=t+"yu";
"я": t:=t+"ya";}
"A": T:=T+"А";
"B": T:=T+"Б";
"V": T:=T+"В";
"G": T:=T+"Г";
"D": T:=T+"Д";
"E": T:=T+"Е";
//"Ё": T:=T+"YE";
//"Ж": T:=T+"ZH";
"Z": T:=T+"Ж";
"I": T:=T+"И";
"Y": T:=T+"Й";
"K": T:=T+"К";
"L": T:=T+"Л";
"M": T:=T+"М";
"N": T:=T+"Н";
"O": T:=T+"О";
"P": T:=T+"П";
"R": T:=T+"Р";
"S": T:=T+"С";
"T": T:=T+"Т";
"U": T:=T+"У";
"F": T:=T+"Ф";
//"Х": T:=T+"CH";
//"Z": T:=T+"Ц";
{"Ч": T:=T+"CH";
"Ш": T:=T+"SH";
"Щ": T:=T+"CH";
"Ъ": T:=T+"""";}
//"Y": T:=T+"Ы";
//"Ь": T:=T+"""";
//"E": T:=T+"Э";
{"Ю": T:=T+"YU";
"Я": T:=T+"YA";}
else
t:=t+s[i];
end;
end;
Result:=t;
end;
function perevod_ (s : String) : String;
var
i, j : Integer;
wantspace : boolean;
Res : String;
begin
Res := "";
for i := 1 to Length(s) do
begin
wantspace := false;
for j:=1 to Length(Eng) do
begin
if Eng[j] = s[i] then
begin
wantspace := true;
break;
end;
end;
if wantspace then Res:=ConCat(Res, Rus[j])
else
Res:=ConCat(Res, s[i]);
end;
perevod_ := Res;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Clear;
if translit.Checked then
memo1.Lines.Add(Translit_(Edit1.Text))
else
memo1.Lines.Add(perevod_(edit1.Text))
end;
end.
← →
Denis_Visma (2004-04-09 17:56) [2]Спасибо большое
← →
TButton © (2004-04-09 19:18) [3]Спасибо, большое =)
← →
SergP © (2004-04-09 19:32) [4]>TButton © (09.04.04 19:18)
>Спасибо, большое =)
Я бы даже сказал:
Огромное, спасибо :)
← →
TButton © (2004-04-09 19:57) [5]а если серьезно, у меня тоже где-то такой валяется. однажды возникла потребность. желание отпало примерно когда половину написал, но не бросать же было. домучал. а оно потом не пригодилось больше =(
← →
SergP © (2004-04-09 22:05) [6]2 TButton © (09.04.04 19:57)
Неужели у тебя и такой же? Не верю...
← →
Adder © (2004-04-09 22:41) [7]Будьте проще... вот, набросала на скорую руку...
function Translate(s:string):string;
const
//ГОСТ 16876-71
LA:array["А".."я"] of string =(
"A","B","V","G","D","E","ZH","Z","I","JJ","K","L",
"M","N","O","P","R","S","T","U","F","KH","C","CH",
"SH","SHH",""","Y","""","EH","JU","JA",
"a","b","v","g","d","e","zh","z","i","jj","k","l",
"m","n","o","p","r","s","t","u","f","kh","c","ch",
"sh","shh",""","y","""","eh","ju","ja");
var i:integer;
begin
result:="";
for i:=1 to Length(s) do
case s[i] of
"Ё": result := result+"YO";
"ё": result := result +"yo";
"А".."я": result := result + LA[s[i]];
else result :=result+s[i];
end;
end;
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2004.04.25;
Скачать: [xml.tar.bz2];
Память: 0.48 MB
Время: 0.036 c