function serviceHeader(){return new ServiceHeader(11,"Yandex","Translate Russian, Spanish, German, French and a number of other languages to and from English. You can translate individual words, as well as whole texts and webpages."+Const.NL2+"https://translate.yandex.com/"+Const.NL2+"\u00a9 2011-2017 \u00abYandex\u00bb",Capability.TRANSLATE|Capability.DETECT_LANGUAGE|Capability.LISTEN)}
function serviceHost(b,a,c){return b===Capability.LISTEN?"https://tts.voicetech.yandex.net":"https://translate.yandex.net"}function serviceLink(b,a,c){var e="https://translate.yandex.com";b&&(a=isLanguage(a)?codeFromLanguage(a):"",c=isLanguage(c)?codeFromLanguage(c):"",e+=format("/?lang={0}-{1}&text={2}",a,c,encodeGetParam(b)));return e}function YandexModel(b){b=prepareSource(b);1E4<b.length&&(b=b.slice(0,1E4));this._makeChunks(b)}YandexModel.prototype.hasChunks=function(){return!!this._chunks.length};
YandexModel.prototype.getNextChunk=function(){return this._chunks.shift()||""};YandexModel.prototype._makeChunks=function(b){var a;for(this._chunks=[];b;){a=this._truncateText(b);if(!a)break;this._chunks.push(a);b=b.slice(a.length)}};
YandexModel.prototype._truncateText=function(b){var a=[/(\n+)/,/([.!?;\u0964](?:\s+|$))/,/([\-\u2012-\u2015](?:\s+|$))/,/([,:](?:\s+|$))/,/([\u3002\uff01\uff1f\uff1b\u2026])/,/([\uff0c\uff1a])/,/(\s+)/];if(!b||600>=b.length)return b;b=b.slice(0,600);for(var c=0;c<a.length;c++){var e=a[c];if(e.test(b))return stringSplit(b,e).slice(0,-1).join("")}return b};
SupportedLanguages=[-1,-1,"af","az","sq","ar","hy","eu","be","bg","ca","zh","zh","hr","cs","da","nl","en","et","fi",-1,"fr","gl","de","el","ht","he","hi","hu","is","id","it","ga","ja","ka","ko","lv","lt","mk","ms","mt","no","fa","pl","pt","ro","ru","sr","sk","sl","es","sw","sv","th","tr","uk","ur","vi","cy","yi","eo",-1,"la","lo","kk","uz","si","tg","te","km","mn","kn","ta","mr"];function appId(){return Options.YandexAppId}
function serviceDetectLanguageRequest(b){var a=format("/api/v1/tr.json/detect?sid={0}&srv=tr-text&text=",appId()),a=a+encodeGetParam(b.slice(0,256));b=getHeader()+Const.NL+"Referer: "+serviceLink();return new RequestData(HttpMethod.GET,a,null,b)}function serviceDetectLanguageResponse(b){return(b=parseJSON(b))&&b.code&&200==b.code?languageFromCode(b.lang):UNKNOWN_LANGUAGE}var yandexModel;
function serviceTranslateRequest(b,a,c){yandexModel||(yandexModel=new YandexModel(b));b=format("/api/v1/tr.json/translate?id={0}-0-0&srv=tr-text&lang={1}-{2}",appId(),codeFromLanguage(a),codeFromLanguage(c));a="text="+encodePostParam(yandexModel.getNextChunk());c=postHeader()+Const.NL+"Referer: "+serviceLink();return new RequestData(HttpMethod.POST,b,a,c,null,"serviceTranslateResponse")}function _useDictionary(b){return b&&100>=b.length&&!/[\n\r]/.test(b)&&3>=b.split(/\s+/).length}
function serviceTranslateResponse(b,a,c,e){(a=parseJSON(a))&&a.code&&200==a.code&&(a=a.text.join("\n"));var d=null;_useDictionary(b)?d="dictionaryRequest":yandexModel.hasChunks()&&(d="serviceTranslateRequest");return new ResponseData(a,c,e,null,d)}
function dictionaryRequest(b,a,c){b=format("/dicservice.json/lookup?srv=tr-text&sid={0}&text={1}&lang={2}-{3}",appId(),encodeGetParam(prepareSource(b)),codeFromLanguage(a),codeFromLanguage(c));return new RequestData(HttpMethod.GET,b,null,null,null,"dictionaryResponse")}
function dictionaryResponse(b,a,c,e){b=parseJSON(a);a="";var d,k;if("object"==typeof b&&b.def)for(var l=0;l<b.def.length;l++){var g=b.def[l];if(g.tr){a+=Const.NL+g.text+(g.ts?" ["+g.ts+"]":"")+" "+g.tr[0].pos+Const.NL;k=g.tr.length;for(var h=0;h<k;h++){var f=g.tr[h];a+=(1<k?h+1+". ":"    ")+f.text;if(f.syn)for(d=0;d<f.syn.length;d++)a+=", "+f.syn[d].text;a+=Const.NL;f.mean&&(a+="    ("+f.mean.map(function(a){return a.text}).join(", ")+")"+Const.NL);if(f.ex)for(d=0;d<f.ex.length;d++){var m=f.ex[d];
a+="        "+m.text+" - "+m.tr.map(function(a){return a.text}).join(", ")+Const.NL}}}}a&&(a=Const.NL+a);return new ResponseData(a,c,e)}
function serviceListenRequest(b,a,c){a=codeFromLanguage(a);switch(a){case "en":a="en_GB";break;case "sv":a="sv_SE";break;case "da":a="da_DK";break;case "cs":a="cs_CZ";break;case "ca":a="ca_ES";break;case "ar":a="ar_AE";break;default:a=a+"_"+a.toUpperCase()}b=format("/tts?format=mp3&quality=hi&platform=web&application=translate&lang={0}&text={1}",a,encodeGetParam(b));c&&(b+="&speed=0.7");return new RequestData(HttpMethod.GET,b)};
