Hi All,
I have a working script on perl, which I use through the service in the Automator.app, I have a desire to adapt this task to applescript, but so far nothing works out.
perl script
So far, I’m only in the process of working transliteration, but my experience is not enough to do it
set theString to "Брин Сергей Михайлович"
--
set RuUp0 to "Й"
set RuUp1 to "Ё"
set RuUp2 to "АБВГДЕЗИКЛМНОПРСТУФЫЭ"
set RuUp3 to "Ж"
set RuUp4 to "Х"
set RuUp5 to "Ц"
set RuUp6 to "Ч"
set RuUp7 to "Ш"
set RuUp8 to "Щ"
set RuUp9 to "Ю"
set RuUp10 to "Я"
--
set RuDown0 to "й"
set RuDown1 to "ё"
set RuDown2 to "абвгдезиклмнопрстуфыэ"
set RuDown3 to "ж"
set RuDown4 to "х"
set RuDown5 to "ц"
set RuDown6 to "ч"
set RuDown7 to "ш"
set RuDown8 to "щ"
set RuDown9 to "ь"
set RuDown10 to "ъ"
set RuDown11 to "ю"
set RuDown12 to "я"
--
set EnUp0 to "Y"
set EnUp1 to "Ye"
set EnUp2 to "ABVGDEZIKLMNOPRSTUFYE"
set EnUp3 to "Zh"
set EnUp4 to "Kh"
set EnUp5 to "Ts"
set EnUp6 to "Ch"
set EnUp7 to "Sh"
set EnUp8 to "Sch"
set EnUp9 to "Yu"
set EnUp10 to "Ya"
--
set EnDown0 to "y"
set EnDown1 to "ye"
set EnDown2 to "abvgdeziklmnoprstufy"
set EnDown3 to "zh"
set EnDown4 to "kh"
set EnDown5 to "ts"
set EnDown6 to "ch"
set EnDown7 to "sh"
set EnDown8 to "sch"
set EnDown9 to ""
set EnDown10 to ""
set EnDown11 to "yu"
set EnDown12 to "ya"
set sourceList to {RuDown0, RuDown1, RuDown2, RuDown3, RuDown4, RuDown5, ¬
RuDown6, RuDown7, RuDown8, RuDown9, RuDown10, RuDown11, RuDown12, ¬
RuUp0, RuUp1, RuUp2, RuUp3, RuUp4, RuUp5, RuUp6, RuUp7, RuUp8, RuUp9, RuUp10} as Unicode text
set targetList to {EnDown0, EnDown1, EnDown2, EnDown3, EnDown4, EnDown5, ¬
EnDown6, EnDown7, EnDown8, EnDown9, EnDown10, EnDown11, EnDown12, ¬
EnUp0, EnUp1, EnUp2, EnUp3, EnUp4, EnUp5, EnUp6, EnUp7, EnUp8, EnUp9, EnUp10} as Unicode text
set translit to {}
repeat with theChar in theString
set sym to offset of theChar in sourceList
if sym is 0 then
set end of translit to contents of theChar
else
set end of translit to character sym of targetList
end if
end repeat
on findReplace(findText, replaceText, sourceText)
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to findText
set sourceText to text items of sourceText
set AppleScript's text item delimiters to replaceText
set sourceText to "" & sourceText
set AppleScript's text item delimiters to ASTID
return sourceText
end findReplace
set translitwithdot to my findReplace({" "}, ".", translit as text)
return translitwithdot as text
The result of this script – “apzm.rdpvdy.lzheyknbzh”, but it should be “Brin.Sergey.Mikhaylovich”
How do I replace the characters correctly?
How do I flip the result and delete the excess?
The result of the execution should be: Sergey.Brin
Do you have any ideas on how to implement it?
Thanks!