termit 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +6 -0
- data/bin/termit +24 -0
- data/lib/termit.rb +11 -0
- data/lib/termit/data_fetcher.rb +25 -0
- data/lib/termit/main.rb +20 -0
- data/lib/termit/sound_response_handler.rb +27 -0
- data/lib/termit/speech_synthesizer.rb +22 -0
- data/lib/termit/text_response_handler.rb +20 -0
- data/lib/termit/text_translator.rb +20 -0
- data/lib/termit/url_constructor.rb +29 -0
- data/lib/termit/user_input_parser.rb +40 -0
- data/lib/termit/version.rb +3 -0
- data/spec/fixtures/google_translate.yml +582 -0
- data/spec/fixtures/text_response +1 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/termit/data_fetcher_spec.rb +19 -0
- data/spec/termit/main_spec.rb +32 -0
- data/spec/termit/sound_response_handler_spec.rb +11 -0
- data/spec/termit/speech_synthesizer_spec.rb +20 -0
- data/spec/termit/text_response_handler_spec.rb +15 -0
- data/spec/termit/text_translator_spec.rb +15 -0
- data/spec/termit/url_constructor_spec.rb +21 -0
- data/spec/termit/user_input_parser_spec.rb +42 -0
- data/termit.gemspec +23 -0
- metadata +143 -0
@@ -0,0 +1 @@
|
|
1
|
+
"<!DOCTYPE html><html><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\"><meta name=keywords content=\"translate, translations, translation, translator, machine translation, online translation\"><meta name=description content=\"Google's free online language translation service instantly translates text and web pages. This translator supports: English, Afrikaans, Albanian, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bosnian, Bulgarian, Catalan, Cebuano, Chinese, Croatian, Czech, Danish, Dutch, Esperanto, Estonian, Filipino, Finnish, French, Galician, Georgian, German, Greek, Gujarati, Haitian Creole, Hebrew, Hindi, Hmong, Hungarian, Icelandic, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Khmer, Korean, Lao, Latin, Latvian, Lithuanian, Macedonian, Malay, Maltese, Marathi, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swahili, Swedish, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Vietnamese, Welsh, Yiddish\"><meta name=robots content=noodp><meta name=google content=notranslate><link rel=\"canonical\" href=\"http://translate.google.com/?tl=pl\"><title>Google Translate</title><link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"/opensearch.xml?hl=en\" title=\"Google Translate\"><script>JS_ERR_COUNT = 0;JS_ERR_ARR = [];function _gtErr(e,url,line){++JS_ERR_COUNT;var i=new Image();var err='e='+e.substr(0,1500)+',url='+url.substr(0,400)+',line='+line+',count='+JS_ERR_COUNT;if (JS_ERR_COUNT<10) {JS_ERR_ARR.push(err);}i.src='/gen204?jserr='+encodeURIComponent(err);i.onload=function(){i.onload=null;};}window.onerror=_gtErr;</script><script>(function(){(function(){function d(a){this.t={};this.tick=function(a,c,b){b=void 0!=b?b:(new Date).getTime();this.t[a]=[b,c]};this.tick(\"start\",null,a)}var a=new d;window.jstiming={Timer:d,load:a};if(window.performance&&window.performance.timing){var a=window.performance.timing,c=window.jstiming.load,b=a.navigationStart,a=a.responseStart;0<b&&a>=b&&(c.tick(\"_wtsrt\",void 0,b),c.tick(\"wtsrt_\",\"_wtsrt\",a),c.tick(\"tbsd_\",\"wtsrt_\"))}try{a=null,window.chrome&&window.chrome.csi&&(a=Math.floor(window.chrome.csi().pageT),\nc&&0<b&&(c.tick(\"_tbnd\",void 0,window.chrome.csi().startE),c.tick(\"tbnd_\",\"_tbnd\",b))),null==a&&window.gtbExternal&&(a=window.gtbExternal.pageT()),null==a&&window.external&&(a=window.external.pageT,c&&0<b&&(c.tick(\"_tbnd\",void 0,window.external.startE),c.tick(\"tbnd_\",\"_tbnd\",b))),a&&(window.jstiming.pt=a)}catch(e){}})();})()\n</script><link rel=stylesheet href=\"/translate/releases/twsfe_w_20130812_RC02/r/css/desktop_ltr.css\"><style>#clir{margin-top:18px;text-align:left}#middle_body{margin-left:10em;border-left:1px solid #c9d7f1;padding-left:1.4em;zoom:1;}</style><style>#gbar,#guser{font-size:13px;padding-right:1px;padding-top:1px !important;}#gbar{padding-left:1px;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}</style><script>window.jstiming.load.tick('cl')</script><script></script></head><body dir=ltr onload=\"window.jstiming.load['tick']('ol');_csi('t','en','pl',document.text_form.text);\"class=\"e_md nj\"><div id=gbar><nobr><a class=gb1 href=\"http://www.google.com/search?tl=pl&ie=UTF-8&oe=UTF-8&hl=en&sa=N&tab=Tw\">Search</a> <a class=gb1 href=\"http://www.google.com/search?tl=pl&ie=UTF-8&oe=UTF-8&hl=en&tbm=isch&source=og&sa=N&tab=Ti\">Images</a> <a class=gb1 href=\"http://maps.google.com/maps?tl=pl&ie=UTF-8&oe=UTF-8&hl=en&sa=N&tab=Tl\">Maps</a> <a class=gb1 href=\"https://play.google.com/?tl=pl&ie=UTF-8&oe=UTF-8&hl=en&sa=N&tab=T8\">Play</a> <a class=gb1 href=\"http://www.youtube.com/results?tl=pl&ie=UTF-8&oe=UTF-8&sa=N&tab=T1\">YouTube</a> <a class=gb1 href=\"http://news.google.com/nwshp?hl=en&tab=Tn\">News</a> <a class=gb1 href=\"https://mail.google.com/mail/?tab=Tm\">Gmail</a> <a class=gb1 href=\"https://drive.google.com/?tab=To\">Drive</a> <a class=gb1 style=\"text-decoration:none\" href=\"http://www.google.com/intl/en/options/\"><u>More</u> »</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe><a href=\"http://www.google.com/support/translate/\" class=gb4>Help</a> | </span><a target=_top id=gb_70 href=\"https://accounts.google.com/ServiceLogin?hl=en&continue=http://translate.google.com/%3Ftl%3Dpl%26sl%3Den%26ie%3DUTF-8%26oe%3DUTF-8\" class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><script>document.body.className=document.body.className.replace('nj','');</script><div id=gt-logo><div id=gt-logo-icon><a href=\"/?hl=en\"><span height=40 alt=\"Google Translate\" border=0 style=\"background:url(http://www.gstatic.com/translate/intl/en/logo2.png) 0 0 no-repeat;width:110px;height:40px;display:inline-block\"></span></a></div></div><div id=gt-c class=g-section><div id=gt-bbar-c><div id=gt-bbar class=goog-inline-block></div></div><input type=hidden id=nc_text value=\"your mother\"><input type=hidden id=nc_sl value=\"en\"><input type=hidden id=nc_tl value=\"pl\"><input type=hidden id=nc_dl value=\"\"><script>MSG_AD_QUERY='';MSG_ALPHA_DESC='This language is still in early stages of development and not yet up to the same quality standards as our other languages.';MSG_ALT_PHRASE_TITLE='Click to edit and see alternate translations';MSG_DISMISS='Dismiss';MSG_BUTTER_BAR_BUTTON = '';MSG_BUTTER_BAR_DESC = '';MSG_CLEAR_TEXT='Clear text';MSG_CLOSE='Close';MSG_DRAG_PHRASE_TIP='';MSG_DRAG_PHRASE_TITLE='Drag with shift key to reorder.';MSG_FILL_SUGGESTION='Contribute a better translation:';MSG_LANGUAGE_CORRECTION='Translate from:';MSG_LISTEN='Listen';MSG_ORIGINAL_TEXT='Original text:';MSG_READ_PHONETICALLY='Read phonetically';MSG_SELECT_ALL = 'Select all';MSG_SPELLING_CORRECTION='Did you mean:';MSG_RELATED_SUGGESTION='See also:';MSG_SUBMIT_SUGGESTION='Submit';MSG_UNDO_EDITS='Undo edits';MSG_USE_ALTERNATIVE='Use';MSG_TTS_EN_AU='Australian';MSG_TTS_EN_US='American';MSG_TTS_EN_GB='British';MSG_TTS_ES_ES='Iberian';MSG_TTS_ES_419='Latin American';MSG_TTS_PT_BR='Brazilian';MSG_TTS_PT_PT='European';MSG_TTS_CMN='Mandarin';MSG_TTS_YUE='Cantonese';msg_disable_otf='Turn off instant translation';msg_enable_otf='Turn on instant translation';tr_in='Translating...';MSG_EXAMPLE_OF_WORD='Example usage of \\x22$word\\x22:';MSG_EXAMPLE_USAGE='Show example usage of words';MSG_MT_FROM_GOOGLE='automatically translated by Google';MSG_NO_EXAMPLE_FOUND='No examples found for \\x22$word\\x22';MSG_CLICK_TO_TRANSLATE='Click to translate';MSG_CHANGE_ITA='Select Input Tool';MSG_IME_OFF='Turn off Input Method';MSG_IME_ON='Turn on Input Method';MSG_VK_OFF='Turn off Virtual Keyboard';MSG_VK_ON='Turn on Virtual Keyboard';MSG_HW_OFF='Turn off Hand Writing';MSG_HW_ON='Turn on Hand Writing';MSG_ALL='All languages';MSG_BACK_TO_ALL='Show all phrases';MSG_DELETE='Delete';MSG_DESTINATION='Destination Text';MSG_EDIT='Edit';MSG_HIDE_PB='Hide Phrasebook';MSG_MY_PB='Phrasebook';MSG_NEW='New!';MSG_NEWEST='Recently added';MSG_NP='Your Phrasebook is empty. Click the star under a translation to save it here.';MSG_NPM='You don\\x27t have any phrases for this language pair.';MSG_OLDEST='Oldest';MSG_PB_ERROR='Oops, something went wrong. Please try again later.';MSG_PB_EXP='Export to Google Sheets';MSG_PB_SR='Search result: %1$s matches.';MSG_PB_TL='Sorry, the phrase you want to save is too long.';MSG_PB_SIGNIN='Sign in to view your Phrasebook.';MSG_SAVE='Save';MSG_SAVED='Saved';MSG_SAVE_PB='Sign in to save to Phrasebook';MSG_SAVING='Saving...';MSG_SHOW_PB='Show Phrasebook';MSG_SORT_BY='Sort';MSG_SOURCE='Original text';MSG_TRANSLATE_FROM_LABEL='From:';MSG_TRANSLATE_TO_LABEL='To:';MSG_VIEW_PB='View my Phrasebook';MSG_HELPFUL='Helpful';MSG_NOT_HELPFUL='Not helpful';MSG_OFFENSIVE='Offensive';MSG_SIGN_IN_TO_RATE='Sign in to rate';MSG_RATE_TRANSLATION='Rate translation';MSG_RATED='Rated:';BUTTER_BAR_URL = '';BUTTER_BAR_LOGTYPE = '';ENCODING = 'UTF-8';DROP_LINK=1;MSG_IS_TRANSLATION_BETTER='Is this translation better than the original?';MSG_SUBMIT_TRANSLATION='Yes, submit translation';MSG_THANK_FOR_SUBMISSION='Thank you for your submission.';WEBFONT=1;AD_TYPE=0;AD_TEST='off';ALPHA_LANGUAGES={'az':1,'bn':1,'ceb':1,'eu':1,'gu':1,'hmn':1,'ht':1,'hy':1,'jw':1,'ka':1,'km':1,'kn':1,'la':1,'lo':1,'mr':1,'ta':1,'te':1,'ur':1};DEFAULT_SOURCES=['en','es','fr'];DEFAULT_TARGETS=['en','es','ar'];DEFAULT_TTS_DIALECT_EN = 'en-GB';DEFAULT_TTS_DIALECT_ES = 'es-ES';DEFAULT_TTS_DIALECT_PT = 'pt-BR';DEFAULT_TTS_DIALECT_ZH = 'zh';LOW_CONFIDENCE_THRESHOLD=-1;MAX_ALTERNATIVES_ROUNDTRIP_RESULTS=1;WEB_TRANSLATION_PATH='/translate';SIGNED_IN=false;USAGE='';</script><div id=gt-form-c><form id=gt-form action=\"/\" name=text_form method=post enctype=\"application/x-www-form-urlencoded\"><div id=gt-appbar><div id=gt-apb-c><div id=gt-apb-main><a id=gt-appname href=\"/\">Translate</a><div id=gt-langs><div id=gt-lang-src><label for=gt-sl class=\"gt-lang-lbl nje\">From:</label><select id=gt-sl name=sl class=\"jfk-button jfk-button-standard nje\" tabindex=0><option SELECTED value=en>English</option><option value=separator disabled>—</option><option value=auto>Detect language</option><option value=separator disabled>—</option><option value=af>Afrikaans</option><option value=sq>Albanian</option><option value=ar>Arabic</option><option value=hy>Armenian</option><option value=az>Azerbaijani</option><option value=eu>Basque</option><option value=be>Belarusian</option><option value=bn>Bengali</option><option value=bs>Bosnian</option><option value=bg>Bulgarian</option><option value=ca>Catalan</option><option value=ceb>Cebuano</option><option value=zh-CN>Chinese</option><option value=hr>Croatian</option><option value=cs>Czech</option><option value=da>Danish</option><option value=nl>Dutch</option><option value=en>English</option><option value=eo>Esperanto</option><option value=et>Estonian</option><option value=tl>Filipino</option><option value=fi>Finnish</option><option value=fr>French</option><option value=gl>Galician</option><option value=ka>Georgian</option><option value=de>German</option><option value=el>Greek</option><option value=gu>Gujarati</option><option value=ht>Haitian Creole</option><option value=iw>Hebrew</option><option value=hi>Hindi</option><option value=hmn>Hmong</option><option value=hu>Hungarian</option><option value=is>Icelandic</option><option value=id>Indonesian</option><option value=ga>Irish</option><option value=it>Italian</option><option value=ja>Japanese</option><option value=jw>Javanese</option><option value=kn>Kannada</option><option value=km>Khmer</option><option value=ko>Korean</option><option value=lo>Lao</option><option value=la>Latin</option><option value=lv>Latvian</option><option value=lt>Lithuanian</option><option value=mk>Macedonian</option><option value=ms>Malay</option><option value=mt>Maltese</option><option value=mr>Marathi</option><option value=no>Norwegian</option><option value=fa>Persian</option><option value=pl>Polish</option><option value=pt>Portuguese</option><option value=ro>Romanian</option><option value=ru>Russian</option><option value=sr>Serbian</option><option value=sk>Slovak</option><option value=sl>Slovenian</option><option value=es>Spanish</option><option value=sw>Swahili</option><option value=sv>Swedish</option><option value=ta>Tamil</option><option value=te>Telugu</option><option value=th>Thai</option><option value=tr>Turkish</option><option value=uk>Ukrainian</option><option value=ur>Urdu</option><option value=vi>Vietnamese</option><option value=cy>Welsh</option><option value=yi>Yiddish</option></select><div id=\"gt-sl-gms\" class=\"goog-inline-block goog-flat-menu-button je\"><div class=\"goog-inline-block goog-flat-menu-button-caption\">From: English</div><div class=\"goog-inline-block goog-flat-menu-button-dropdown\"></div></div></div><div id=gt-swap title=\"Swap languages\"class=\"jfk-button-standard jfk-button-narrow jfk-button trans-swap-button je\"><span class=\"jfk-button-img\"></span></div><div id=gt-lang-tgt><label for=gt-tl class=\"gt-lang-lbl nje\">To:</label><select id=gt-tl name=tl class=\"jfk-button jfk-button-standard nje\" tabindex=0><option SELECTED value=pl>Polish</option><option value=separator disabled>—</option><option value=af>Afrikaans</option><option value=sq>Albanian</option><option value=ar>Arabic</option><option value=hy>Armenian</option><option value=az>Azerbaijani</option><option value=eu>Basque</option><option value=be>Belarusian</option><option value=bn>Bengali</option><option value=bs>Bosnian</option><option value=bg>Bulgarian</option><option value=ca>Catalan</option><option value=ceb>Cebuano</option><option value=zh-CN>Chinese (Simplified)</option><option value=zh-TW>Chinese (Traditional)</option><option value=hr>Croatian</option><option value=cs>Czech</option><option value=da>Danish</option><option value=nl>Dutch</option><option value=en>English</option><option value=eo>Esperanto</option><option value=et>Estonian</option><option value=tl>Filipino</option><option value=fi>Finnish</option><option value=fr>French</option><option value=gl>Galician</option><option value=ka>Georgian</option><option value=de>German</option><option value=el>Greek</option><option value=gu>Gujarati</option><option value=ht>Haitian Creole</option><option value=iw>Hebrew</option><option value=hi>Hindi</option><option value=hmn>Hmong</option><option value=hu>Hungarian</option><option value=is>Icelandic</option><option value=id>Indonesian</option><option value=ga>Irish</option><option value=it>Italian</option><option value=ja>Japanese</option><option value=jw>Javanese</option><option value=kn>Kannada</option><option value=km>Khmer</option><option value=ko>Korean</option><option value=lo>Lao</option><option value=la>Latin</option><option value=lv>Latvian</option><option value=lt>Lithuanian</option><option value=mk>Macedonian</option><option value=ms>Malay</option><option value=mt>Maltese</option><option value=mr>Marathi</option><option value=no>Norwegian</option><option value=fa>Persian</option><option value=pl>Polish</option><option value=pt>Portuguese</option><option value=ro>Romanian</option><option value=ru>Russian</option><option value=sr>Serbian</option><option value=sk>Slovak</option><option value=sl>Slovenian</option><option value=es>Spanish</option><option value=sw>Swahili</option><option value=sv>Swedish</option><option value=ta>Tamil</option><option value=te>Telugu</option><option value=th>Thai</option><option value=tr>Turkish</option><option value=uk>Ukrainian</option><option value=ur>Urdu</option><option value=vi>Vietnamese</option><option value=cy>Welsh</option><option value=yi>Yiddish</option></select><div id=\"gt-tl-gms\" class=\"goog-inline-block goog-flat-menu-button je\"><div class=\"goog-inline-block goog-flat-menu-button-caption\">To: Polish</div><div class=\"goog-inline-block goog-flat-menu-button-dropdown\"></div></div></div><div id=gt-lang-submit><input type=submit id=gt-submit value=\"Translate\" tabindex=0 class=\"jfk-button jfk-button-action\"></div></div></div></div></div><div id=gt-text-all><div id=gt-main><div id=gt-text-c><div id=gt-text-top><div id=gt-src-c class=g-unit><div id=gt-src-p><input type=hidden name=js value=n id=js><input type=hidden name=prev value=\"_t\" id=prev><input type=hidden name=hl value=\"en\" id=hl><input type=hidden name=ie value=\"UTF-8\"><div id=gt-sl-sugg class=\"gt-lang-sugg-message goog-inline-block je\"><div class=\"goog-inline-block goog-toolbar-button goog-toolbar-button-checked\"><div class=\"goog-inline-block goog-toolbar-button-outer-box\"><div class=\"goog-inline-block goog-toolbar-button-inner-box\">English</div></div></div><div class=\"goog-inline-block goog-toolbar-button\"><div class=\"goog-inline-block goog-toolbar-button-outer-box\"><div class=\"goog-inline-block goog-toolbar-button-inner-box\">Spanish</div></div></div><div class=\"goog-inline-block goog-toolbar-button\"><div class=\"goog-inline-block goog-toolbar-button-outer-box\"><div class=\"goog-inline-block goog-toolbar-button-inner-box\">French</div></div></div></div><div id=gt-src-wrap><label for=source style=\"display:none\">Translate text or webpage</label><div style=\"width: 100%;\"><textarea id=source name=text wrap=SOFT tabindex=0 dir=\"ltr\" spellcheck=\"false\" autocapitalize=\"off\" autocomplete=\"off\" autocorrect=\"off\" >your mother</textarea></div><script>(function(){var src = document.getElementById('source');src.focus();src.select();src.style.boxSizing=src.style.WebkitBoxSizing=src.style.MozBoxSizing=src.style.MsBoxSizing='border-box';})();</script><div id=gt-src-tools><div id=gt-src-tools-l></div><div id=gt-src-tools-r></div></div></div> <div id=select_document style=\"display:none\">Type text or a website address or <a href=\"/?tr=f&hl=en\">translate a document.</a></div><div id=file_div class=file style=\"display:none\"><div id=select_text><a href=\"/?tr=t&hl=en\">Cancel</a></div><input type=file name=file id=file size=40></div><div id=src-translit class=translit dir=ltr style=\"text-align:;display:none\"></div><div id=spelling-correction style=\"display:none\"></div><div id=gt-src-ex></div></div> </div> <div id=gt-res-c class=g-unit><div id=gt-res-p><div id=gt-res-data><div id=gt-tl-sugg class=\"gt-lang-sugg-message goog-inline-block je\"><div class=\"goog-inline-block goog-toolbar-button goog-toolbar-button-checked\"><div class=\"goog-inline-block goog-toolbar-button-outer-box\"><div class=\"goog-inline-block goog-toolbar-button-inner-box\">Polish</div></div></div><div class=\"goog-inline-block goog-toolbar-button\"><div class=\"goog-inline-block goog-toolbar-button-outer-box\"><div class=\"goog-inline-block goog-toolbar-button-inner-box\">English</div></div></div><div class=\"goog-inline-block goog-toolbar-button\"><div class=\"goog-inline-block goog-toolbar-button-outer-box\"><div class=\"goog-inline-block goog-toolbar-button-inner-box\">Spanish</div></div></div></div><div id=gt-res-wrap><div id=\"gt-res-content\" class=almost_half_cell><div dir=\"ltr\" style=\"zoom:1\"><div id=\"tts_button\" style=\"display:none\" class=\"\"><object type=\"application/x-shockwave-flash\" data=\"//ssl.gstatic.com/translate/sound_player2.swf\" width=\"18\" height=\"18\" id=\"tts\"><param value=\"//ssl.gstatic.com/translate/sound_player2.swf\" name=\"movie\"/><param value=\"sound_name_cb=_TTSSoundFile\" name=\"flashvars\"/><param value=\"transparent\" name=\"wmode\"/><param value=\"always\" name=\"allowScriptAccess\"/></object></div><span id=result_box class=\"short_text\"><span title=\"your mother\" onmouseover=\"this.style.backgroundColor='#ebeff9'\" onmouseout=\"this.style.backgroundColor='#fff'\">Twoja matka</span></span></div></div><div id=gt-res-tools><div id=gt-res-tools-l><div id=gt-pb-star></div><div id=gt-res-undo><a id=gt-undo style=\"display:none\"></a></div></div><div id=gt-res-tools-r><div id=\"gt-alpha\" class=\"goog-inline-block\"style=\"display:none\">Alpha</div></div></div></div><div id=res-translit class=translit dir=ltr style=\"text-align:\"></div><div id=gt-res-ex></div><div id=gt-res-dict style=\"display:none\"><h3>Dictionary</h3></div></div></div></div></div><div id=gt-question-promo><span class=\"jfk-butterBar jfk-butterBar-shown jfk-butterBar-info\">Would you mind <a target=_blank>answering some questions</a> to help improve translation quality?</span></div><div id=gt-ft><div id=gt-ft-mkt><div class=gt-ft-promos><span class=gt-ft-text>Google Translate for Business:</span><a href=\"http://www.google.com/url?source=transpromo&rs=rsmf&q=http://translate.google.com/toolkit%3Fhl%3Den\"><span id=\"gt-ft-mkt-toolkit\" class=gt-ft-mkt-icon></span>Translator Toolkit</a><a href=\"http://www.google.com/url?source=transpromo&rs=rsmf&q=http://translate.google.com/manager/website/%3Fhl%3Den\"><span id=\"gt-ft-mkt-element\" class=gt-ft-mkt-icon></span>Website Translator</a><a href=\"http://www.google.com/url?source=transpromo&rs=rsmf&q=http://translate.google.com/globalmarketfinder/%3Flocale%3Den\"><span id=\"gt-ft-mkt-gmf\" class=gt-ft-mkt-icon></span>Global Market Finder</a></div></div> </div></div></div></div></form></div><script>{window.jstiming.load.tick('rsw');window.jstiming.load.tick('rsl');window.jstiming.load.tick('rtl');function _njClk(e){document.body.className+=' nj';var i=new Image();i.src='/gen204?njclk=1';i.onload=function(){i.onload=null;};}var slgms=document.getElementById('gt-sl-gms');var tlgms= document.getElementById('gt-tl-gms');slgms.onclick=tlgms.onclock=_njClk;}</script><div id=\"gt-dd-filelink-help\" style=\"display:none\">Drag and drop file or link here to translate the document or web page.</div><div id=\"gt-dd-link-help\" style=\"display:none\">Drag and drop link here to translate the web page.</div><div id=\"gt-dd-file-error\" style=\"display:none\">We do not support the type of file you drop. Please try other file types.</div><div id=\"gt-dd-link-error\" style=\"display:none\">We do not support the type of link you drop. Please try link of other types.</div><div id=gt-ft-res><span id=ft-l><a id=gt-otf-switch href=\"/?hl=en&eotf=0&sl=en&tl=pl&q=your+mother\">Turn off instant translation</a></span><span id=ft-r><a href=\"http://www.google.com/url?source=transpromo&rs=rssf&q=http://translate.google.com/about/intl/en_ALL/\">About Google Translate</a><a href=\"http://www.google.com/url?source=transpromo&rs=rssf&q=http://www.google.com/mobile/translate/\">Mobile</a><a href=\"http://www.google.com/url?source=transpromo&rs=rssf&q=http://www.google.com/intl/en/privacy.html\">Privacy</a><a href=\"http://www.google.com/url?source=transpromo&rs=rssf&q=http://www.google.com/support/translate/\">Help</a><a href=\"javascript:void(0);\" id=\"gt-feedback\">Send feedback</a></span></div> <script>MSG_GOOGLE_TRANSLATE='Google Translate';common_translation_tooltip='Common translation';detect_language='Detect language';n_more_label='+ %1$s more';rare_translation_tooltip='Rare translation';source_language_detected='%1$s - detected';uncommon_translation_tooltip='Uncommon translation';url_hyperlink_tooltip='View translated webpage';MSG_PUBLIC_EVAL_PATH='';MSG_PUBLIC_EVAL_PATH='/question';REORDERING=1;EXPERIMENT_IDS = [];FILE_TRANSLATION_PATH='http://translate.googleusercontent.com/translate_f';PUBLIC_EVAL_LANGUAGE_PAIRS={};PUBLIC_EVAL_LANGUAGE_PAIRS={\"ceb/en\":true,\"en/ceb\":true,\"en/ha\":true,\"en/ig\":true,\"en/kk\":true,\"en/km\":true,\"en/ky\":true,\"en/mi\":true,\"en/mn\":true,\"en/ne\":true,\"en/pa\":true,\"en/so\":true,\"en/tg\":true,\"en/yi\":true,\"en/yo\":true,\"en/zu\":true,\"ha/en\":true,\"ig/en\":true,\"kk/en\":true,\"km/en\":true,\"ky/en\":true,\"mi/en\":true,\"mn/en\":true,\"ne/en\":true,\"pa/en\":true,\"so/en\":true,\"tg/en\":true,\"yo/en\":true,\"zu/en\":true}\n;TEXT_TRANSLATION_PATH='/';TR_ASYNC_JS_PATH='/translate/releases/twsfe_w_20130812_RC02/r/js/desktop_module_async.js';TR_LAZY_JS_PATH='/translate/releases/twsfe_w_20130812_RC02/r/js/desktop_module_lazy.js';TTS_TEXT_SIZE_LIMIT=100;TRANSLATED_TEXT='Twoja matka';INPUT_TOOL_PATH='//www.google.com';var ctr, h;tld='.com';FEATURE_STICKINESS=[[[\"en\"],[\"pl\"],[[\"en\",\"pl\"]],0],1];</script><script src=\"/translate/releases/twsfe_w_20130812_RC02/r/js/desktop_module_main.js\"></script><script>window.jstiming.load.tick('br');Init();window.jstiming.load.tick('prt');</script><script>TR_ASYNC_JS_PATH&&LoadJsModule(TR_ASYNC_JS_PATH);</script></div> </body></html>"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'vcr'
|
4
|
+
require 'webmock/rspec'
|
5
|
+
|
6
|
+
require_relative '../lib/termit'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# some (optional) config here
|
10
|
+
end
|
11
|
+
|
12
|
+
VCR.configure do |c|
|
13
|
+
c.cassette_library_dir = 'spec/fixtures/'
|
14
|
+
c.hook_into :webmock
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Termit::DataFetcher do
|
4
|
+
describe "data method" do
|
5
|
+
let(:url) { "http://translate.google.com/?tl=fr&sl=en&ie=UTF-8&oe=UTF-8" }
|
6
|
+
let(:text) { "it would require two large integer variables to store her weight, else she would cause a buffer overflow." }
|
7
|
+
it "should send the correct POST request" do
|
8
|
+
fetcher = Termit::DataFetcher.new url, text
|
9
|
+
Net::HTTP.should_receive(:new)
|
10
|
+
request = double 'fake_request'
|
11
|
+
http = double 'fake_http', request: :good_response
|
12
|
+
Net::HTTP::Post.stub(:new) { request }
|
13
|
+
Net::HTTP::stub(:new) { http }
|
14
|
+
http.should_receive(:request).with(request)
|
15
|
+
request.should_receive(:set_form_data).with(text: text)
|
16
|
+
fetcher.data.should eq :good_response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Termit::Main do
|
5
|
+
describe "translate" do
|
6
|
+
before do
|
7
|
+
text_translator = double 'fake_text_tranlsator', call: nil, text: :result
|
8
|
+
Termit::TextTranslator.stub(:new) { text_translator }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "voice flag is set to false" do
|
12
|
+
it "executes only the TextTranslator" do
|
13
|
+
Termit::TextTranslator.should_receive(:new)
|
14
|
+
Termit::SpeechSynthesizer.should_not_receive(:new)
|
15
|
+
Termit::Main.new(source_lang: :pl, target_lang: :en, text: 'cześć i czołem').translate
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "voice flag is set to true" do
|
20
|
+
before do
|
21
|
+
speech_synthesizer = double 'fake_speech_synthesizer', call: :sound
|
22
|
+
Termit::SpeechSynthesizer.stub(:new) { speech_synthesizer }
|
23
|
+
end
|
24
|
+
|
25
|
+
it "executes both TextTranslator and SpeechSynthesizer" do
|
26
|
+
Termit::TextTranslator.should_receive(:new)
|
27
|
+
Termit::SpeechSynthesizer.should_receive(:new)
|
28
|
+
Termit::Main.new(source_lang: :pl, target_lang: :en, text: 'cześć i czołem', voice: true).translate
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Termit::SpeechSynthesizer do
|
5
|
+
describe "call" do
|
6
|
+
before do
|
7
|
+
response = double 'fake_response', body: :binary_sound_file
|
8
|
+
fetcher = double 'fake_fetcher', data: response
|
9
|
+
handler = double 'fake_sound_handler', call: :nothing
|
10
|
+
Termit::DataFetcher.stub(:new) { fetcher }
|
11
|
+
Termit::SoundResponseHandler.stub(:new) { handler }
|
12
|
+
end
|
13
|
+
|
14
|
+
it "executes correct service objects" do
|
15
|
+
Termit::SpeechSynthesizer.any_instance.stub(:check_sound_player) { nil }
|
16
|
+
Termit::SoundResponseHandler.should_receive(:new).with(:binary_sound_file)
|
17
|
+
Termit::SpeechSynthesizer.new(target_lang: :en, text: 'your mother', voice: true).call
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Termit::TextResponseHandler do
|
4
|
+
describe "call method" do
|
5
|
+
let(:handler) do
|
6
|
+
response_body = File.open('spec/fixtures/text_response').read
|
7
|
+
Termit::TextResponseHandler.new(response_body)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "extracts data from HTTP response body" do
|
11
|
+
expect(handler.call).to eq('Twoja matka')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Termit::TextTranslator do
|
5
|
+
#end to end testing seding real request to Google Translate !!add VCR!!
|
6
|
+
describe "translated_text" do
|
7
|
+
it "translates text correctly" do
|
8
|
+
VCR.use_cassette('google_translate') do
|
9
|
+
translator = Termit::TextTranslator.new source_lang: :en, target_lang: :pl, text: 'hey cowboy where is your horse'
|
10
|
+
translator.call
|
11
|
+
expect(translator.text).to eq 'hey cowboy gdzie jest twój koń'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Termit::UrlConstructor do
|
4
|
+
describe "url method" do
|
5
|
+
context "when voice flag is set to false" do
|
6
|
+
it "returns correctly formatted url" do
|
7
|
+
url_formatter = Termit::UrlConstructor.new source_lang: :en, target_lang: :fr, text: 'your mother', voice: false
|
8
|
+
url = "http://translate.google.com/?tl=fr&sl=en&ie=UTF-8&oe=UTF-8"
|
9
|
+
expect(url_formatter.url).to eq(url)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when voice flag is set to false" do
|
14
|
+
it "returns correctly formatted url" do
|
15
|
+
url_formatter = Termit::UrlConstructor.new target_lang: :fr, text: 'your mother', voice: true
|
16
|
+
url = "http://translate.google.com/translate_tts?tl=fr&ie=UTF-8&oe=UTF-8"
|
17
|
+
expect(url_formatter.url).to eq(url)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Termit::UserInputParser do
|
4
|
+
describe "initialization" do
|
5
|
+
it "raises error if argument is not a ARGV options array" do
|
6
|
+
expect { Termit::UserInputParser.new :wrong_data }.to raise_error ArgumentError
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "options method" do
|
11
|
+
context "when user has not given any arguments" do
|
12
|
+
it "raises error" do
|
13
|
+
parser = Termit::UserInputParser.new []
|
14
|
+
expect{ parser.options }.to raise_error SystemExit
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when user has specified the options" do
|
19
|
+
it "without the -v flag" do
|
20
|
+
parser = Termit::UserInputParser.new ['en', 'fr', 'your mother']
|
21
|
+
expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother', voice: false })
|
22
|
+
end
|
23
|
+
|
24
|
+
it "with the -v flag" do
|
25
|
+
parser = Termit::UserInputParser.new ['en', 'fr', 'your mother', '-v']
|
26
|
+
expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother', voice: true })
|
27
|
+
end
|
28
|
+
|
29
|
+
it "with text as seperate ARGV array elements" do
|
30
|
+
parser = Termit::UserInputParser.new ['en', 'fr', 'your', 'mother', 'here?', '-v']
|
31
|
+
expect(parser.options).to eq({ source_lang: :en, target_lang: :fr, text: 'your mother here?', voice: true })
|
32
|
+
end
|
33
|
+
|
34
|
+
it "with incorrect language options format raiser error" do
|
35
|
+
parser = Termit::UserInputParser.new ['anglicki', 'po polski', 'your mother', '-v']
|
36
|
+
expect{ parser.options }.to raise_error SystemExit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/termit.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'termit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "termit"
|
8
|
+
gem.version = Termit::VERSION
|
9
|
+
gem.authors = ["pawurb"]
|
10
|
+
gem.email = ["p.urbanek89@gmail.com"]
|
11
|
+
gem.summary = %q{Google Translate in your terminal}
|
12
|
+
gem.description = %q{ Termit is an easy way to use all the Google Translate goodies straight from your terminal. }
|
13
|
+
gem.homepage = "http://github.com/pawurb/termit"
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.executables = ['termit']
|
16
|
+
gem.test_files = gem.files.grep(%r{^(spec)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.add_development_dependency "rspec", '~> 2.14.1'
|
20
|
+
gem.add_development_dependency "vcr", '~> 2.5.0'
|
21
|
+
gem.add_development_dependency "webmock", '~> 1.12.0'
|
22
|
+
gem.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: termit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pawurb
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.14.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.14.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: vcr
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.5.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.12.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.12.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: ! ' Termit is an easy way to use all the Google Translate goodies straight
|
70
|
+
from your terminal. '
|
71
|
+
email:
|
72
|
+
- p.urbanek89@gmail.com
|
73
|
+
executables:
|
74
|
+
- termit
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- .rspec
|
80
|
+
- .travis.yml
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/termit
|
86
|
+
- lib/termit.rb
|
87
|
+
- lib/termit/data_fetcher.rb
|
88
|
+
- lib/termit/main.rb
|
89
|
+
- lib/termit/sound_response_handler.rb
|
90
|
+
- lib/termit/speech_synthesizer.rb
|
91
|
+
- lib/termit/text_response_handler.rb
|
92
|
+
- lib/termit/text_translator.rb
|
93
|
+
- lib/termit/url_constructor.rb
|
94
|
+
- lib/termit/user_input_parser.rb
|
95
|
+
- lib/termit/version.rb
|
96
|
+
- spec/fixtures/google_translate.yml
|
97
|
+
- spec/fixtures/text_response
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- spec/termit/data_fetcher_spec.rb
|
100
|
+
- spec/termit/main_spec.rb
|
101
|
+
- spec/termit/sound_response_handler_spec.rb
|
102
|
+
- spec/termit/speech_synthesizer_spec.rb
|
103
|
+
- spec/termit/text_response_handler_spec.rb
|
104
|
+
- spec/termit/text_translator_spec.rb
|
105
|
+
- spec/termit/url_constructor_spec.rb
|
106
|
+
- spec/termit/user_input_parser_spec.rb
|
107
|
+
- termit.gemspec
|
108
|
+
homepage: http://github.com/pawurb/termit
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.0.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Google Translate in your terminal
|
132
|
+
test_files:
|
133
|
+
- spec/fixtures/google_translate.yml
|
134
|
+
- spec/fixtures/text_response
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/termit/data_fetcher_spec.rb
|
137
|
+
- spec/termit/main_spec.rb
|
138
|
+
- spec/termit/sound_response_handler_spec.rb
|
139
|
+
- spec/termit/speech_synthesizer_spec.rb
|
140
|
+
- spec/termit/text_response_handler_spec.rb
|
141
|
+
- spec/termit/text_translator_spec.rb
|
142
|
+
- spec/termit/url_constructor_spec.rb
|
143
|
+
- spec/termit/user_input_parser_spec.rb
|