[РЕШЕНО]google-translater

hi all, запилил себе переводчика через google-transater и notify.
код из аура
function wgets()
{
  wget --referer="http://www.google.com" --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" \
  --header="Accept:text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" \
  --header="Accept-Language: en-us,en;q=0.5" \
  --header="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" \
  --header="Keep-Alive: 300" "[email protected]"
}
tle=$(wgets "http://translate.google.ru/translate_a/t?client=x&text=$3&hl=$1&sl=$1&tl=$2" -qO-)
echo $tle | awk -F\" '{ print $6 }'

Короткие фразы переводит без проблем, ну вот "войну и мир" нехочет. Переводит только определённое количество символов.
как то так:
$ ~/script/translate/translate.sh auto ru "Well, Prince, so Genoa and Lucca are now just family estates of the Buonapartes. But I warn you, if you don't tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist - I really believe he is Antichrist - I will have nothing more to do with you and you are no longer my friend, no longer my 'faithful slave,' as you call yourself! But how do you do? I see I have frightened you - sit down and tell me all the news."
Ну, князь, так Генуя и Лукка теперь только семейные имения в Buonapartes.
на самом деле:
$ ~/script/translate/translate.sh auto ru "Well, Prince, so Genoa and Lucca are now just family estates of the Buonapartes. But I warn you, if you don't tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist - I really believe he is Antichrist - I will have nothing more to do with you and you are no longer my friend, no longer my 'faithful slave,' as you call yourself! But how do you do? I see I have frightened you - sit down and tell me all the news.
{"sentences":[{"trans":"Ну, князь, так Генуя и Лукка теперь только семейные имения в Buonapartes. ","orig":"Well, Prince, so Genoa and Lucca are now just family estates of the Buonapartes.","translit":"Nu, knyaz', tak Genuya i Lukka teper' tol'ko semeynyye imeniya v Buonapartes. ","src_translit":""},{"trans":"Но предупреждаю, если вы не говорите мне, что это означает войну, если вы все еще пытаются защитить гнусности и ужасы, совершенные, что антихрист - Я действительно верю, что он Антихрист - у меня не будет ничего общего с вами и вас ","orig":"But I warn you, if you don't tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist - I really believe he is Antichrist - I will have nothing more to do with you and you","translit":"No preduprezhdayu, yesli vy ne govorite mne, chto eto oznachayet voynu, yesli vy vse yeshche pytayutsya zashchitit' gnusnosti i uzhasy, sovershennyye, chto antikhrist - YA deystvitel'no veryu, chto on Antikhrist - u menya ne budet nichego obshchego s vami i vas ","src_translit":""},{"trans":"больше не мой друг, больше не мой \"верный раб», как вы называете себя! ","orig":"are no longer my friend, no longer my 'faithful slave,' as you call yourself!","translit":"bol'she ne moy drug, bol'she ne moy \"vernyy rab», kak vy nazyvayete sebya! ","src_translit":""},{"trans":"Но как вы это делаете? ","orig":"But how do you do?","translit":"No kak vy eto delayete? ","src_translit":""},{"trans":"Я вижу, что напугали вас - сесть и сказать мне все новости.","orig":"I see I have frightened you - sit down and tell me all the news.","translit":"YA vizhu, chto napugali vas - sest' i skazat' mne vse novosti.","src_translit":""}],"src":"en","server_time":2}

Автор решил не парится
awk -F\" '{ print $6 }'
жаль его способ дальше не работает(
Я думал как то, на таком принципе запилить. Но как то всё очень разрослось и в итоге н*****а не получилось((
sed -e 's/.*"trans":"\(.*\)","orig":".*/\1/'
Может кто уже для себя подправил?
Ошибки в тексте-неповторимый стиль автора©
разделите строку по вот такому куску
{"trans":
например так
IFS=";;;"; for item in $(echo "$tle" | sed "s/{\"trans\":/;;;/g"); do [[ ${item::1} == '"' ]] && echo "$item" | awk -F'"' '{printf $2;}'; done; echo ""
Если по шагам. Сначала говорим, что разделитель элементов три ;, потом цикл с заменой в строке выражения на эти три ;. Потом смотрим являетя ли первый символ кавычками, если да то разбиваем строку по кавычкам и вырисовывам второй кусок (printf - без подстановки \n в конце строк). В конце вставляем перенос каретки

замечу только, что все это стремно и костыльно =)
PGP 0x31361F01
arcanisrepo
трохи костыльненько, но вё равно большое спасибо.
Ошибки в тексте-неповторимый стиль автора©
p.s. сори, решил дальше непарится и ипользовал yandex api v1.5 внём оказывается уже тоже есть auto-detect lang)
Ошибки в тексте-неповторимый стиль автора©
 
Зарегистрироваться или войдите чтобы оставить сообщение.