1
0

trans 193 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713
  1. #!/usr/bin/env bash
  2. export TRANS_ENTRY="$0"
  3. if [[ ! $LANG =~ (UTF|utf)-?8$ ]]; then export LANG=en_US.UTF-8; fi
  4. read -r -d '' TRANS_PROGRAM << 'EOF'
  5. BEGIN {
  6. Name = "Translate Shell"
  7. Description = "Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc."
  8. Version = "0.9.6.12"
  9. ReleaseDate = "2020-05-11"
  10. Command = "trans"
  11. EntryPoint = "translate.awk"
  12. EntryScript = "translate"
  13. }
  14. function initConst() {
  15. NULLSTR = ""
  16. NONE = "\0"
  17. TRUE = 1
  18. STDIN = "/dev/stdin"
  19. STDOUT = "/dev/stdout"
  20. STDERR = "/dev/stderr"
  21. SUPOUT = " > /dev/null "
  22. SUPERR = " 2> /dev/null "
  23. PIPE = " | "
  24. }
  25. function anything(array,
  26. i) {
  27. for (i in array)
  28. if (array[i]) return 1
  29. return 0
  30. }
  31. function exists(value) {
  32. if (isarray(value))
  33. return anything(value)
  34. else
  35. return value ? 1 : 0
  36. }
  37. function belongsTo(element, array,
  38. i) {
  39. for (i in array)
  40. if (element == array[i]) return element
  41. return NULLSTR
  42. }
  43. function identical(x, y,
  44. i) {
  45. if (!isarray(x) && !isarray(y))
  46. return x == y
  47. else if (isarray(x) && isarray(y)) {
  48. if (length(x) != length(y)) return 0
  49. for (i in x)
  50. if (!identical(x[i], y[i])) return 0
  51. return 1
  52. } else
  53. return 0
  54. }
  55. function append(array, element) {
  56. array[anything(array) ? length(array) : 0] = element
  57. }
  58. function compareByIndexFields(i1, v1, i2, v2,
  59. t1, t2, tl, j) {
  60. split(i1, t1, SUBSEP)
  61. split(i2, t2, SUBSEP)
  62. tl = length(t1) < length(t2) ? length(t1) : length(t2)
  63. for (j = 1; j <= tl; j++) {
  64. if (t1[j] < t2[j])
  65. return -1
  66. else if (t1[j] > t2[j])
  67. return 1
  68. }
  69. return 0
  70. }
  71. function isnum(string) {
  72. return string == string + 0
  73. }
  74. function startsWithAny(string, substrings,
  75. i) {
  76. for (i in substrings)
  77. if (index(string, substrings[i]) == 1) return substrings[i]
  78. return NULLSTR
  79. }
  80. function matchesAny(string, patterns,
  81. i) {
  82. for (i in patterns)
  83. if (string ~ "^" patterns[i]) return patterns[i]
  84. return NULLSTR
  85. }
  86. function replicate(string, len,
  87. i, temp) {
  88. temp = NULLSTR
  89. for (i = 0; i < len; i++)
  90. temp = temp string
  91. return temp
  92. }
  93. function reverse(string,
  94. i, temp) {
  95. temp = NULLSTR
  96. for (i = length(string); i > 0; i--)
  97. temp = temp substr(string, i, 1);
  98. return temp
  99. }
  100. function join(array, separator, sortedIn, preserveNull,
  101. i, j, saveSortedIn, temp) {
  102. if (!sortedIn)
  103. sortedIn = "compareByIndexFields"
  104. temp = NULLSTR
  105. j = 0
  106. if (isarray(array)) {
  107. saveSortedIn = PROCINFO["sorted_in"]
  108. PROCINFO["sorted_in"] = sortedIn
  109. for (i in array)
  110. if (preserveNull || array[i] != NULLSTR)
  111. temp = j++ ? temp separator array[i] : array[i]
  112. PROCINFO["sorted_in"] = saveSortedIn
  113. } else
  114. temp = array
  115. return temp
  116. }
  117. function explode(string, array) {
  118. split(string, array, NULLSTR)
  119. }
  120. function escapeChar(char) {
  121. switch (char) {
  122. case "b":
  123. return "\b"
  124. case "f":
  125. return "\f"
  126. case "n":
  127. return "\n"
  128. case "r":
  129. return "\r"
  130. case "t":
  131. return "\t"
  132. case "v":
  133. return "\v"
  134. case "u0026":
  135. return "&"
  136. case "u003c":
  137. return "<"
  138. case "u003e":
  139. return ">"
  140. case "u200b":
  141. return ""
  142. default:
  143. return char
  144. }
  145. }
  146. function literal(string,
  147. c, cc, escaping, i, s) {
  148. if (string !~ /^".*"$/)
  149. return string
  150. explode(string, s)
  151. string = NULLSTR
  152. escaping = 0
  153. for (i = 2; i < length(s); i++) {
  154. c = s[i]
  155. if (escaping) {
  156. if (cc) {
  157. cc = cc c
  158. if (length(cc) == 5) {
  159. string = string escapeChar(cc)
  160. escaping = 0
  161. cc = NULLSTR
  162. }
  163. } else if (c == "u") {
  164. cc = c
  165. } else {
  166. string = string escapeChar(c)
  167. escaping = 0
  168. }
  169. } else {
  170. if (c == "\\")
  171. escaping = 1
  172. else
  173. string = string c
  174. }
  175. }
  176. return string
  177. }
  178. function escape(string) {
  179. gsub(/\\/, "\\\\", string)
  180. gsub(/"/, "\\\"", string)
  181. return string
  182. }
  183. function unescape(string) {
  184. gsub(/\\"/, "\"", string)
  185. gsub(/\\\\/, "\\", string)
  186. return string
  187. }
  188. function parameterize(string, quotationMark) {
  189. if (!quotationMark)
  190. quotationMark = "'"
  191. if (quotationMark == "'") {
  192. gsub(/'/, "'\\''", string)
  193. return "'" string "'"
  194. } else {
  195. return "\"" escape(string) "\""
  196. }
  197. }
  198. function unparameterize(string, temp) {
  199. match(string, /^'(.*)'$/, temp)
  200. if (temp[0]) {
  201. string = temp[1]
  202. gsub(/'\\''/, "'", string)
  203. return string
  204. }
  205. match(string, /^"(.*)"$/, temp)
  206. if (temp[0]) {
  207. string = temp[1]
  208. return unescape(string)
  209. }
  210. return string
  211. }
  212. function toString(value, inline, heredoc, valOnly, numSub, level, sortedIn,
  213. i, items, j, k, p, saveSortedIn, temp, v) {
  214. if (!level) level = 0
  215. if (!sortedIn)
  216. sortedIn = "compareByIndexFields"
  217. if (isarray(value)) {
  218. saveSortedIn = PROCINFO["sorted_in"]
  219. PROCINFO["sorted_in"] = sortedIn
  220. p = 0
  221. for (i in value) {
  222. split(i, j, SUBSEP); k = join(j, ",")
  223. if (!numSub || !isnum(k)) k = parameterize(k, "\"")
  224. v = toString(value[i], inline, heredoc, valOnly, numSub, level + 1, sortedIn)
  225. if (!isarray(value[i])) v = parameterize(v, "\"")
  226. if (valOnly)
  227. items[p++] = inline ? v : (replicate("\t", level) v)
  228. else
  229. items[p++] = inline ? (k ": " v) :
  230. (replicate("\t", level) k "\t" v)
  231. }
  232. PROCINFO["sorted_in"] = saveSortedIn
  233. temp = inline ? join(items, ", ") :
  234. ("\n" join(items, "\n") "\n" replicate("\t", level))
  235. temp = valOnly ? ("[" temp "]") : ("{" temp "}")
  236. return temp
  237. } else {
  238. if (heredoc)
  239. return "'''\n" value "\n'''"
  240. else
  241. return value
  242. }
  243. }
  244. function squeeze(line, preserveIndent) {
  245. if (!preserveIndent)
  246. gsub(/^[[:space:]]+/, NULLSTR, line)
  247. gsub(/^[[:space:]]*#.*$/, NULLSTR, line)
  248. gsub(/#[^"/]*$/, NULLSTR, line)
  249. gsub(/[[:space:]]+$/, NULLSTR, line)
  250. gsub(/[[:space:]]+\\$/, "\\", line)
  251. return line
  252. }
  253. function yn(string) {
  254. return (tolower(string) ~ /^([0fn]|off)/) ? 0 : 1
  255. }
  256. function initAnsiCode() {
  257. if (ENVIRON["TERM"] == "dumb") return
  258. AnsiCode["reset"] = AnsiCode[0] = "\33[0m"
  259. AnsiCode["bold"] = "\33[1m"
  260. AnsiCode["underline"] = "\33[4m"
  261. AnsiCode["negative"] = "\33[7m"
  262. AnsiCode["no bold"] = "\33[22m"
  263. AnsiCode["no underline"] = "\33[24m"
  264. AnsiCode["positive"] = "\33[27m"
  265. AnsiCode["black"] = "\33[30m"
  266. AnsiCode["red"] = "\33[31m"
  267. AnsiCode["green"] = "\33[32m"
  268. AnsiCode["yellow"] = "\33[33m"
  269. AnsiCode["blue"] = "\33[34m"
  270. AnsiCode["magenta"] = "\33[35m"
  271. AnsiCode["cyan"] = "\33[36m"
  272. AnsiCode["gray"] = "\33[37m"
  273. AnsiCode["default"] = "\33[39m"
  274. AnsiCode["dark gray"] = "\33[90m"
  275. AnsiCode["light red"] = "\33[91m"
  276. AnsiCode["light green"] = "\33[92m"
  277. AnsiCode["light yellow"] = "\33[93m"
  278. AnsiCode["light blue"] = "\33[94m"
  279. AnsiCode["light magenta"] = "\33[95m"
  280. AnsiCode["light cyan"] = "\33[96m"
  281. AnsiCode["white"] = "\33[97m"
  282. }
  283. function ansi(code, text) {
  284. switch (code) {
  285. case "bold":
  286. return AnsiCode[code] text AnsiCode["no bold"]
  287. case "underline":
  288. return AnsiCode[code] text AnsiCode["no underline"]
  289. case "negative":
  290. return AnsiCode[code] text AnsiCode["positive"]
  291. default:
  292. return AnsiCode[code] text AnsiCode[0]
  293. }
  294. }
  295. function w(text) {
  296. print ansi("yellow", text) > STDERR
  297. }
  298. function e(text) {
  299. print ansi("bold", ansi("yellow", text)) > STDERR
  300. }
  301. function wtf(text) {
  302. print ansi("bold", ansi("red", text)) > STDERR
  303. }
  304. function d(text) {
  305. print ansi("gray", text) > STDERR
  306. }
  307. function da(value, name, inline, heredoc, valOnly, numSub, sortedIn,
  308. i, j, saveSortedIn) {
  309. if (!name)
  310. name = "_"
  311. if (!sortedIn)
  312. sortedIn = "compareByIndexFields"
  313. d(name " = " toString(value, inline, heredoc, valOnly, numSub, 0, sortedIn))
  314. }
  315. function assert(x, message) {
  316. if (!message)
  317. message = "[ERROR] Assertion failed."
  318. if (x)
  319. return x
  320. else
  321. e(message)
  322. }
  323. function initUrlEncoding() {
  324. UrlEncoding["\t"] = "%09"
  325. UrlEncoding["\n"] = "%0A"
  326. UrlEncoding[" "] = "%20"
  327. UrlEncoding["!"] = "%21"
  328. UrlEncoding["\""] = "%22"
  329. UrlEncoding["#"] = "%23"
  330. UrlEncoding["$"] = "%24"
  331. UrlEncoding["%"] = "%25"
  332. UrlEncoding["&"] = "%26"
  333. UrlEncoding["'"] = "%27"
  334. UrlEncoding["("] = "%28"
  335. UrlEncoding[")"] = "%29"
  336. UrlEncoding["*"] = "%2A"
  337. UrlEncoding["+"] = "%2B"
  338. UrlEncoding[","] = "%2C"
  339. UrlEncoding["-"] = "%2D"
  340. UrlEncoding["."] = "%2E"
  341. UrlEncoding["/"] = "%2F"
  342. UrlEncoding[":"] = "%3A"
  343. UrlEncoding[";"] = "%3B"
  344. UrlEncoding["<"] = "%3C"
  345. UrlEncoding["="] = "%3D"
  346. UrlEncoding[">"] = "%3E"
  347. UrlEncoding["?"] = "%3F"
  348. UrlEncoding["@"] = "%40"
  349. UrlEncoding["["] = "%5B"
  350. UrlEncoding["\\"] = "%5C"
  351. UrlEncoding["]"] = "%5D"
  352. UrlEncoding["^"] = "%5E"
  353. UrlEncoding["_"] = "%5F"
  354. UrlEncoding["`"] = "%60"
  355. UrlEncoding["{"] = "%7B"
  356. UrlEncoding["|"] = "%7C"
  357. UrlEncoding["}"] = "%7D"
  358. UrlEncoding["~"] = "%7E"
  359. }
  360. function quote(string, i, r, s) {
  361. r = NULLSTR
  362. explode(string, s)
  363. for (i = 1; i <= length(s); i++)
  364. r = r (s[i] in UrlEncoding ? UrlEncoding[s[i]] : s[i])
  365. return r
  366. }
  367. function unquote(string, i, k, r, s, temp) {
  368. r = NULLSTR
  369. explode(string, s)
  370. temp = NULLSTR
  371. for (i = 1; i <= length(s); i++)
  372. if (temp) {
  373. temp = temp s[i]
  374. if (length(temp) > 2) {
  375. for (k in UrlEncoding)
  376. if (temp == UrlEncoding[k]) {
  377. r = r k
  378. temp = NULLSTR
  379. break
  380. }
  381. if (temp) {
  382. r = r temp
  383. temp = NULLSTR
  384. }
  385. }
  386. } else {
  387. if (s[i] != "%")
  388. r = r s[i]
  389. else
  390. temp = s[i]
  391. }
  392. if (temp)
  393. r = r temp
  394. return r
  395. }
  396. function initUriSchemes() {
  397. UriSchemes[0] = "file://"
  398. UriSchemes[1] = "http://"
  399. UriSchemes[2] = "https://"
  400. }
  401. function readFrom(file, line, text) {
  402. if (!file) file = "/dev/stdin"
  403. text = NULLSTR
  404. while (getline line < file)
  405. text = (text ? text "\n" : NULLSTR) line
  406. return text
  407. }
  408. function writeTo(text, file) {
  409. if (!file) file = "/dev/stdout"
  410. print text > file
  411. }
  412. function getOutput(command, content, line) {
  413. content = NULLSTR
  414. while ((command |& getline line) > 0)
  415. content = (content ? content "\n" : NULLSTR) line
  416. close(command)
  417. return content
  418. }
  419. function fileExists(file) {
  420. return !system("test -f " parameterize(file))
  421. }
  422. function dirExists(file) {
  423. return !system("test -d " parameterize(file))
  424. }
  425. function detectProgram(prog, arg, returnOutput, command, temp) {
  426. command = prog " " arg SUPERR
  427. command | getline temp
  428. close(command)
  429. if (returnOutput)
  430. return temp
  431. if (temp)
  432. return prog
  433. return NULLSTR
  434. }
  435. function getGitHead( line, group) {
  436. if (fileExists(".git/HEAD")) {
  437. getline line < ".git/HEAD"
  438. match(line, /^ref: (.*)$/, group)
  439. if (fileExists(".git/" group[1])) {
  440. getline line < (".git/" group[1])
  441. return substr(line, 1, 7)
  442. } else
  443. return NULLSTR
  444. } else
  445. return NULLSTR
  446. }
  447. BEGIN {
  448. initConst()
  449. initAnsiCode()
  450. initUrlEncoding()
  451. initUriSchemes()
  452. }
  453. function initGawk( group) {
  454. Gawk = "gawk"
  455. GawkVersion = PROCINFO["version"]
  456. split(PROCINFO["version"], group, ".")
  457. if (group[1] < 4) {
  458. e("[ERROR] Oops! Your gawk (version " GawkVersion ") "\
  459. "appears to be too old.\n"\
  460. " You need at least gawk 4.0.0 to run this program.")
  461. exit 1
  462. }
  463. }
  464. function initBiDiTerm() {
  465. if (ENVIRON["MLTERM"])
  466. BiDiTerm = "mlterm"
  467. else if (ENVIRON["KONSOLE_VERSION"])
  468. BiDiTerm = "konsole"
  469. }
  470. function initBiDi() {
  471. FriBidi = detectProgram("fribidi", "--version", 1)
  472. BiDiNoPad = FriBidi ? "fribidi --nopad" : "rev" SUPERR
  473. BiDi = FriBidi ? "fribidi --width %s" :
  474. "rev" SUPERR "| sed \"s/'/\\\\\\'/\" | xargs -0 printf '%%%ss'"
  475. }
  476. function initRlwrap() {
  477. Rlwrap = detectProgram("rlwrap", "--version")
  478. }
  479. function initEmacs() {
  480. Emacs = detectProgram("emacs", "--version")
  481. }
  482. function initCurl() {
  483. Curl = detectProgram("curl", "--version")
  484. }
  485. function l(value, name, inline, heredoc, valOnly, numSub, sortedIn) {
  486. if (Option["debug"]) {
  487. if (name)
  488. da(value, name, inline, heredoc, valOnly, numSub, sortedIn)
  489. else
  490. d(value)
  491. }
  492. }
  493. function m(string) {
  494. if (Option["debug"])
  495. return ansi("cyan", string) RS
  496. }
  497. function newerVersion(ver1, ver2, i, group1, group2) {
  498. split(ver1, group1, ".")
  499. split(ver2, group2, ".")
  500. for (i = 1; i <= 4; i++) {
  501. if (group1[i] + 0 > group2[i] + 0)
  502. return 1
  503. else if (group1[i] + 0 < group2[i] + 0)
  504. return 0
  505. }
  506. return 0
  507. }
  508. function rlwrapMe( i, command) {
  509. initRlwrap()
  510. if (!Rlwrap) {
  511. l(">> not found: rlwrap")
  512. return 1
  513. }
  514. if (ENVIRON["TRANS_ENTRY"]) {
  515. command = Rlwrap " " ENVIRON["TRANS_ENTRY"] " "\
  516. parameterize("-no-rlwrap")
  517. } else if (fileExists(ENVIRON["TRANS_DIR"] "/" EntryScript)) {
  518. command = Rlwrap " sh "\
  519. parameterize(ENVIRON["TRANS_DIR"] "/" EntryScript)\
  520. " - " parameterize("-no-rlwrap")
  521. } else {
  522. l(">> not found: $TRANS_ENTRY or EntryPoint")
  523. return 1
  524. }
  525. for (i = 1; i < length(ARGV); i++)
  526. if (ARGV[i])
  527. command = command " " parameterize(ARGV[i])
  528. l(">> forking: " command)
  529. if (!system(command)) {
  530. l(">> process exited with code 0")
  531. exit ExitCode
  532. } else {
  533. l(">> process exited with non-zero return code")
  534. return 1
  535. }
  536. }
  537. function emacsMe( i, params, el, command) {
  538. initEmacs()
  539. if (!Emacs) {
  540. l(">> not found: emacs")
  541. return 1
  542. }
  543. params = ""
  544. for (i = 1; i < length(ARGV); i++)
  545. if (ARGV[i])
  546. params = params " " parameterize(ARGV[i], "\"")
  547. if (ENVIRON["TRANS_ENTRY"]) {
  548. el = "(progn (setq explicit-shell-file-name \"" ENVIRON["TRANS_ENTRY"] "\") "\
  549. "(setq explicit-" Command "-args '(\"-I\" \"-no-rlwrap\"" params ")) "\
  550. "(command-execute 'shell) (rename-buffer \"" Name "\"))"
  551. } else if (fileExists(ENVIRON["TRANS_DIR"] "/" EntryScript)) {
  552. el = "(progn (setq explicit-shell-file-name \"" "sh" "\") "\
  553. "(setq explicit-" "sh" "-args '(\"" ENVIRON["TRANS_DIR"] "/" EntryScript "\" \"-I\" \"-no-rlwrap\"" params ")) "\
  554. "(command-execute 'shell) (rename-buffer \"" Name "\"))"
  555. } else {
  556. l(">> not found: $TRANS_ENTRY or EntryPoint")
  557. return 1
  558. }
  559. command = Emacs " --eval " parameterize(el)
  560. l(">> forking: " command)
  561. if (!system(command)) {
  562. l(">> process exited with code 0")
  563. exit ExitCode
  564. } else {
  565. l(">> process exited with non-zero return code")
  566. return 1
  567. }
  568. }
  569. function curl(url, output, command, content, line) {
  570. initCurl()
  571. if (!Curl) {
  572. l(">> not found: curl")
  573. w("[WARNING] curl is not found.")
  574. return NULLSTR
  575. }
  576. command = Curl " --location --silent"
  577. if (Option["proxy"])
  578. command = command " --proxy " parameterize(Option["proxy"])
  579. if (Option["user-agent"])
  580. command = command " --user-agent " parameterize(Option["user-agent"])
  581. command = command " " parameterize(url)
  582. if (output) {
  583. command = command " --output " parameterize(output)
  584. system(command)
  585. return NULLSTR
  586. }
  587. content = NULLSTR
  588. while ((command |& getline line) > 0)
  589. content = (content ? content "\n" : NULLSTR) line
  590. close(command)
  591. return content
  592. }
  593. function curlPost(url, data, output, command, content, line) {
  594. initCurl()
  595. if (!Curl) {
  596. l(">> not found: curl")
  597. w("[WARNING] curl is not found.")
  598. return NULLSTR
  599. }
  600. command = Curl " --location --silent"
  601. if (Option["proxy"])
  602. command = command " --proxy " parameterize(Option["proxy"])
  603. if (Option["user-agent"])
  604. command = command " --user-agent " parameterize(Option["user-agent"])
  605. command = command " --request POST --data " parameterize(data)
  606. command = command " " parameterize(url)
  607. if (output) {
  608. command = command " --output " parameterize(output)
  609. system(command)
  610. return NULLSTR
  611. }
  612. content = NULLSTR
  613. while ((command |& getline line) > 0)
  614. content = (content ? content "\n" : NULLSTR) line
  615. close(command)
  616. return content
  617. }
  618. function dump(text, group, command, temp) {
  619. command = "hexdump" " -v -e'1/1 \"%03u\" \" \"'"
  620. command = "echo " parameterize(text) PIPE command
  621. command | getline temp
  622. split(temp, group, " ")
  623. close(command)
  624. return length(group) - 1
  625. }
  626. function dumpX(text, group, command, temp) {
  627. command = "hexdump" " -v -e'1/1 \"%02X\" \" \"'"
  628. command = "echo " parameterize(text) PIPE command
  629. command | getline temp
  630. split(temp, group, " ")
  631. close(command)
  632. return length(group) - 1
  633. }
  634. function base64(text, command, temp) {
  635. if (detectProgram("uname", "-s", 1) == "Linux")
  636. command = "echo -n " parameterize(text) PIPE "base64 -w0"
  637. else
  638. command = "echo -n " parameterize(text) PIPE "base64"
  639. command = "bash -c " parameterize(command, "\"")
  640. command | getline temp
  641. close(command)
  642. return temp
  643. }
  644. function uprintf(text, command, temp) {
  645. command = "echo -en " parameterize(text)
  646. command = "bash -c " parameterize(command, "\"")
  647. command | getline temp
  648. close(command)
  649. return temp
  650. }
  651. function initLocale() {
  652. Locale["af"]["name"] = "Afrikaans"
  653. Locale["af"]["endonym"] = "Afrikaans"
  654. Locale["af"]["translations-of"] = "Vertalings van %s"
  655. Locale["af"]["definitions-of"] = "Definisies van %s"
  656. Locale["af"]["synonyms"] = "Sinonieme"
  657. Locale["af"]["examples"] = "Voorbeelde"
  658. Locale["af"]["see-also"] = "Sien ook"
  659. Locale["af"]["family"] = "Indo-European"
  660. Locale["af"]["iso"] = "afr"
  661. Locale["af"]["glotto"] = "afri1274"
  662. Locale["af"]["script"] = "Latn"
  663. Locale["sq"]["name"] = "Albanian"
  664. Locale["sq"]["endonym"] = "Shqip"
  665. Locale["sq"]["translations-of"] = "Përkthimet e %s"
  666. Locale["sq"]["definitions-of"] = "Përkufizime të %s"
  667. Locale["sq"]["synonyms"] = "Sinonime"
  668. Locale["sq"]["examples"] = "Shembuj"
  669. Locale["sq"]["see-also"] = "Shihni gjithashtu"
  670. Locale["sq"]["family"] = "Indo-European"
  671. Locale["sq"]["iso"] = "sqi"
  672. Locale["sq"]["glotto"] = "alba1267"
  673. Locale["sq"]["script"] = "Latn"
  674. Locale["am"]["name"] = "Amharic"
  675. Locale["am"]["endonym"] = "አማርኛ"
  676. Locale["am"]["translations-of"] = "የ %s ትርጉሞች"
  677. Locale["am"]["definitions-of"] = "የ %s ቃላት ፍችዎች"
  678. Locale["am"]["synonyms"] = "ተመሳሳይ ቃላት"
  679. Locale["am"]["examples"] = "ምሳሌዎች"
  680. Locale["am"]["see-also"] = "የሚከተለውንም ይመልከቱ"
  681. Locale["am"]["family"] = "Afro-Asiatic"
  682. Locale["am"]["iso"] = "amh"
  683. Locale["am"]["glotto"] = "amha1245"
  684. Locale["am"]["script"] = "Ethi"
  685. Locale["ar"]["name"] = "Arabic"
  686. Locale["ar"]["endonym"] = "العربية"
  687. Locale["ar"]["translations-of"] = "ترجمات %s"
  688. Locale["ar"]["definitions-of"] = "تعريفات %s"
  689. Locale["ar"]["synonyms"] = "مرادفات"
  690. Locale["ar"]["examples"] = "أمثلة"
  691. Locale["ar"]["see-also"] = "انظر أيضًا"
  692. Locale["ar"]["family"] = "Afro-Asiatic"
  693. Locale["ar"]["iso"] = "ara"
  694. Locale["ar"]["glotto"] = "stan1318"
  695. Locale["ar"]["script"] = "Arab"
  696. Locale["ar"]["rtl"] = "true"
  697. Locale["hy"]["name"] = "Armenian"
  698. Locale["hy"]["endonym"] = "Հայերեն"
  699. Locale["hy"]["translations-of"] = "%s-ի թարգմանությունները"
  700. Locale["hy"]["definitions-of"] = "%s-ի սահմանումները"
  701. Locale["hy"]["synonyms"] = "Հոմանիշներ"
  702. Locale["hy"]["examples"] = "Օրինակներ"
  703. Locale["hy"]["see-also"] = "Տես նաև"
  704. Locale["hy"]["family"] = "Indo-European"
  705. Locale["hy"]["iso"] = "hye"
  706. Locale["hy"]["glotto"] = "nucl1235"
  707. Locale["hy"]["script"] = "Armn"
  708. Locale["az"]["name"] = "Azerbaijani"
  709. Locale["az"]["endonym"] = "Azərbaycanca"
  710. Locale["az"]["translations-of"] = "%s sözünün tərcüməsi"
  711. Locale["az"]["definitions-of"] = "%s sözünün tərifləri"
  712. Locale["az"]["synonyms"] = "Sinonimlər"
  713. Locale["az"]["examples"] = "Nümunələr"
  714. Locale["az"]["see-also"] = "Həmçinin, baxın:"
  715. Locale["az"]["family"] = "Turkic"
  716. Locale["az"]["iso"] = "aze"
  717. Locale["az"]["glotto"] = "nort2697"
  718. Locale["az"]["script"] = "Latn"
  719. Locale["eu"]["name"] = "Basque"
  720. Locale["eu"]["endonym"] = "Euskara"
  721. Locale["eu"]["translations-of"] = "%s esapidearen itzulpena"
  722. Locale["eu"]["definitions-of"] = "Honen definizioak: %s"
  723. Locale["eu"]["synonyms"] = "Sinonimoak"
  724. Locale["eu"]["examples"] = "Adibideak"
  725. Locale["eu"]["see-also"] = "Ikusi hauek ere"
  726. Locale["eu"]["family"] = "Language Isolate"
  727. Locale["eu"]["iso"] = "eus"
  728. Locale["eu"]["glotto"] = "basq1248"
  729. Locale["eu"]["script"] = "Latn"
  730. Locale["be"]["name"] = "Belarusian"
  731. Locale["be"]["endonym"] = "беларуская"
  732. Locale["be"]["translations-of"] = "Пераклады %s"
  733. Locale["be"]["definitions-of"] = "Вызначэннi %s"
  734. Locale["be"]["synonyms"] = "Сінонімы"
  735. Locale["be"]["examples"] = "Прыклады"
  736. Locale["be"]["see-also"] = "Гл. таксама"
  737. Locale["be"]["family"] = "Indo-European"
  738. Locale["be"]["iso"] = "bel"
  739. Locale["be"]["glotto"] = "bela1254"
  740. Locale["be"]["script"] = "Cyrl"
  741. Locale["bn"]["name"] = "Bengali"
  742. Locale["bn"]["endonym"] = "বাংলা"
  743. Locale["bn"]["translations-of"] = "%s এর অনুবাদ"
  744. Locale["bn"]["definitions-of"] = "%s এর সংজ্ঞা"
  745. Locale["bn"]["synonyms"] = "প্রতিশব্দ"
  746. Locale["bn"]["examples"] = "উদাহরণ"
  747. Locale["bn"]["see-also"] = "আরো দেখুন"
  748. Locale["bn"]["family"] = "Indo-European"
  749. Locale["bn"]["iso"] = "ben"
  750. Locale["bn"]["glotto"] = "beng1280"
  751. Locale["bn"]["script"] = "Beng"
  752. Locale["bs"]["name"] = "Bosnian"
  753. Locale["bs"]["endonym"] = "Bosanski"
  754. Locale["bs"]["translations-of"] = "Prijevod za: %s"
  755. Locale["bs"]["definitions-of"] = "Definicije za %s"
  756. Locale["bs"]["synonyms"] = "Sinonimi"
  757. Locale["bs"]["examples"] = "Primjeri"
  758. Locale["bs"]["see-also"] = "Pogledajte i"
  759. Locale["bs"]["family"] = "Indo-European"
  760. Locale["bs"]["iso"] = "bos"
  761. Locale["bs"]["glotto"] = "bosn1245"
  762. Locale["bs"]["script"] = "Latn"
  763. Locale["bg"]["name"] = "Bulgarian"
  764. Locale["bg"]["endonym"] = "български"
  765. Locale["bg"]["translations-of"] = "Преводи на %s"
  766. Locale["bg"]["definitions-of"] = "Дефиниции за %s"
  767. Locale["bg"]["synonyms"] = "Синоними"
  768. Locale["bg"]["examples"] = "Примери"
  769. Locale["bg"]["see-also"] = "Вижте също"
  770. Locale["bg"]["family"] = "Indo-European"
  771. Locale["bg"]["iso"] = "bul"
  772. Locale["bg"]["glotto"] = "bulg1262"
  773. Locale["bg"]["script"] = "Cyrl"
  774. Locale["ca"]["name"] = "Catalan"
  775. Locale["ca"]["endonym"] = "Català"
  776. Locale["ca"]["translations-of"] = "Traduccions per a %s"
  777. Locale["ca"]["definitions-of"] = "Definicions de: %s"
  778. Locale["ca"]["synonyms"] = "Sinònims"
  779. Locale["ca"]["examples"] = "Exemples"
  780. Locale["ca"]["see-also"] = "Vegeu també"
  781. Locale["ca"]["family"] = "Indo-European"
  782. Locale["ca"]["iso"] = "cat"
  783. Locale["ca"]["glotto"] = "stan1289"
  784. Locale["ca"]["script"] = "Latn"
  785. Locale["ceb"]["name"] = "Cebuano"
  786. Locale["ceb"]["endonym"] = "Cebuano"
  787. Locale["ceb"]["translations-of"] = "%s Mga Paghubad sa PULONG_O_HUGPONG SA PAMULONG"
  788. Locale["ceb"]["definitions-of"] = "Mga kahulugan sa %s"
  789. Locale["ceb"]["synonyms"] = "Mga Kapulong"
  790. Locale["ceb"]["examples"] = "Mga pananglitan:"
  791. Locale["ceb"]["see-also"] = "Kitaa pag-usab"
  792. Locale["ceb"]["family"] = "Austronesian"
  793. Locale["ceb"]["iso"] = "ceb"
  794. Locale["ceb"]["glotto"] = "cebu1242"
  795. Locale["ceb"]["script"] = "Latn"
  796. Locale["ny"]["name"] = "Chichewa"
  797. Locale["ny"]["endonym"] = "Nyanja"
  798. Locale["ny"]["translations-of"] = "Matanthauzidwe a %s"
  799. Locale["ny"]["definitions-of"] = "Mamasulidwe a %s"
  800. Locale["ny"]["synonyms"] = "Mau ofanana"
  801. Locale["ny"]["examples"] = "Zitsanzo"
  802. Locale["ny"]["see-also"] = "Onaninso"
  803. Locale["ny"]["family"] = "Atlantic-Congo"
  804. Locale["ny"]["iso"] = "nya"
  805. Locale["ny"]["glotto"] = "nyan1308"
  806. Locale["ny"]["script"] = "Latn"
  807. Locale["zh-CN"]["name"] = "Chinese Simplified"
  808. Locale["zh-CN"]["endonym"] = "简体中文"
  809. Locale["zh-CN"]["translations-of"] = "%s 的翻译"
  810. Locale["zh-CN"]["definitions-of"] = "%s的定义"
  811. Locale["zh-CN"]["synonyms"] = "同义词"
  812. Locale["zh-CN"]["examples"] = "示例"
  813. Locale["zh-CN"]["see-also"] = "另请参阅"
  814. Locale["zh-CN"]["family"] = "Sino-Tibetan"
  815. Locale["zh-CN"]["iso"] = "zho-CN"
  816. Locale["zh-CN"]["glotto"] = "mand1415"
  817. Locale["zh-CN"]["script"] = "Hans"
  818. Locale["zh-CN"]["dictionary"] = "true"
  819. Locale["zh-TW"]["name"] = "Chinese Traditional"
  820. Locale["zh-TW"]["endonym"] = "正體中文"
  821. Locale["zh-TW"]["translations-of"] = "「%s」的翻譯"
  822. Locale["zh-TW"]["definitions-of"] = "「%s」的定義"
  823. Locale["zh-TW"]["synonyms"] = "同義詞"
  824. Locale["zh-TW"]["examples"] = "例句"
  825. Locale["zh-TW"]["see-also"] = "另請參閱"
  826. Locale["zh-TW"]["family"] = "Sino-Tibetan"
  827. Locale["zh-TW"]["iso"] = "zho-TW"
  828. Locale["zh-TW"]["glotto"] = "mand1415"
  829. Locale["zh-TW"]["script"] = "Hant"
  830. Locale["zh-TW"]["dictionary"] = "true"
  831. Locale["co"]["name"] = "Corsican"
  832. Locale["co"]["endonym"] = "Corsu"
  833. Locale["co"]["translations-of"] = "Traductions de %s"
  834. Locale["co"]["definitions-of"] = "Définitions de %s"
  835. Locale["co"]["synonyms"] = "Synonymes"
  836. Locale["co"]["examples"] = "Exemples"
  837. Locale["co"]["see-also"] = "Voir aussi"
  838. Locale["co"]["family"] = "Indo-European"
  839. Locale["co"]["iso"] = "cos"
  840. Locale["co"]["glotto"] = "cors1242"
  841. Locale["co"]["script"] = "Latn"
  842. Locale["hr"]["name"] = "Croatian"
  843. Locale["hr"]["endonym"] = "Hrvatski"
  844. Locale["hr"]["translations-of"] = "Prijevodi riječi ili izraza %s"
  845. Locale["hr"]["definitions-of"] = "Definicije riječi ili izraza %s"
  846. Locale["hr"]["synonyms"] = "Sinonimi"
  847. Locale["hr"]["examples"] = "Primjeri"
  848. Locale["hr"]["see-also"] = "Također pogledajte"
  849. Locale["hr"]["family"] = "Indo-European"
  850. Locale["hr"]["iso"] = "hrv"
  851. Locale["hr"]["glotto"] = "croa1245"
  852. Locale["hr"]["script"] = "Latn"
  853. Locale["cs"]["name"] = "Czech"
  854. Locale["cs"]["endonym"] = "Čeština"
  855. Locale["cs"]["translations-of"] = "Překlad výrazu %s"
  856. Locale["cs"]["definitions-of"] = "Definice výrazu %s"
  857. Locale["cs"]["synonyms"] = "Synonyma"
  858. Locale["cs"]["examples"] = "Příklady"
  859. Locale["cs"]["see-also"] = "Viz také"
  860. Locale["cs"]["family"] = "Indo-European"
  861. Locale["cs"]["iso"] = "ces"
  862. Locale["cs"]["glotto"] = "czec1258"
  863. Locale["cs"]["script"] = "Latn"
  864. Locale["da"]["name"] = "Danish"
  865. Locale["da"]["endonym"] = "Dansk"
  866. Locale["da"]["translations-of"] = "Oversættelser af %s"
  867. Locale["da"]["definitions-of"] = "Definitioner af %s"
  868. Locale["da"]["synonyms"] = "Synonymer"
  869. Locale["da"]["examples"] = "Eksempler"
  870. Locale["da"]["see-also"] = "Se også"
  871. Locale["da"]["family"] = "Indo-European"
  872. Locale["da"]["iso"] = "dan"
  873. Locale["da"]["glotto"] = "dani1285"
  874. Locale["da"]["script"] = "Latn"
  875. Locale["nl"]["name"] = "Dutch"
  876. Locale["nl"]["endonym"] = "Nederlands"
  877. Locale["nl"]["translations-of"] = "Vertalingen van %s"
  878. Locale["nl"]["definitions-of"] = "Definities van %s"
  879. Locale["nl"]["synonyms"] = "Synoniemen"
  880. Locale["nl"]["examples"] = "Voorbeelden"
  881. Locale["nl"]["see-also"] = "Zie ook"
  882. Locale["nl"]["family"] = "Indo-European"
  883. Locale["nl"]["iso"] = "nld"
  884. Locale["nl"]["glotto"] = "dutc1256"
  885. Locale["nl"]["script"] = "Latn"
  886. Locale["nl"]["dictionary"] = "true"
  887. Locale["en"]["name"] = "English"
  888. Locale["en"]["endonym"] = "English"
  889. Locale["en"]["translations-of"] = "Translations of %s"
  890. Locale["en"]["definitions-of"] = "Definitions of %s"
  891. Locale["en"]["synonyms"] = "Synonyms"
  892. Locale["en"]["examples"] = "Examples"
  893. Locale["en"]["see-also"] = "See also"
  894. Locale["en"]["family"] = "Indo-European"
  895. Locale["en"]["iso"] = "eng"
  896. Locale["en"]["glotto"] = "stan1293"
  897. Locale["en"]["script"] = "Latn"
  898. Locale["en"]["dictionary"] = "true"
  899. Locale["eo"]["name"] = "Esperanto"
  900. Locale["eo"]["endonym"] = "Esperanto"
  901. Locale["eo"]["translations-of"] = "Tradukoj de %s"
  902. Locale["eo"]["definitions-of"] = "Difinoj de %s"
  903. Locale["eo"]["synonyms"] = "Sinonimoj"
  904. Locale["eo"]["examples"] = "Ekzemploj"
  905. Locale["eo"]["see-also"] = "Vidu ankaŭ"
  906. Locale["eo"]["family"] = "Artificial Language"
  907. Locale["eo"]["iso"] = "epo"
  908. Locale["eo"]["glotto"] = "espe1235"
  909. Locale["eo"]["script"] = "Latn"
  910. Locale["et"]["name"] = "Estonian"
  911. Locale["et"]["endonym"] = "Eesti"
  912. Locale["et"]["translations-of"] = "Sõna(de) %s tõlked"
  913. Locale["et"]["definitions-of"] = "Sõna(de) %s definitsioonid"
  914. Locale["et"]["synonyms"] = "Sünonüümid"
  915. Locale["et"]["examples"] = "Näited"
  916. Locale["et"]["see-also"] = "Vt ka"
  917. Locale["et"]["family"] = "Uralic"
  918. Locale["et"]["iso"] = "est"
  919. Locale["et"]["glotto"] = "esto1258"
  920. Locale["et"]["script"] = "Latn"
  921. Locale["tl"]["name"] = "Filipino"
  922. Locale["tl"]["endonym"] = "Tagalog"
  923. Locale["tl"]["translations-of"] = "Mga pagsasalin ng %s"
  924. Locale["tl"]["definitions-of"] = "Mga kahulugan ng %s"
  925. Locale["tl"]["synonyms"] = "Mga Kasingkahulugan"
  926. Locale["tl"]["examples"] = "Mga Halimbawa"
  927. Locale["tl"]["see-also"] = "Tingnan rin ang"
  928. Locale["tl"]["family"] = "Austronesian"
  929. Locale["tl"]["iso"] = "tgl"
  930. Locale["tl"]["glotto"] = "taga1270"
  931. Locale["tl"]["script"] = "Latn"
  932. Locale["fi"]["name"] = "Finnish"
  933. Locale["fi"]["endonym"] = "Suomi"
  934. Locale["fi"]["translations-of"] = "Käännökset tekstille %s"
  935. Locale["fi"]["definitions-of"] = "Määritelmät kohteelle %s"
  936. Locale["fi"]["synonyms"] = "Synonyymit"
  937. Locale["fi"]["examples"] = "Esimerkkejä"
  938. Locale["fi"]["see-also"] = "Katso myös"
  939. Locale["fi"]["family"] = "Uralic"
  940. Locale["fi"]["iso"] = "fin"
  941. Locale["fi"]["glotto"] = "finn1318"
  942. Locale["fi"]["script"] = "Latn"
  943. Locale["fr"]["name"] = "French"
  944. Locale["fr"]["endonym"] = "Français"
  945. Locale["fr"]["translations-of"] = "Traductions de %s"
  946. Locale["fr"]["definitions-of"] = "Définitions de %s"
  947. Locale["fr"]["synonyms"] = "Synonymes"
  948. Locale["fr"]["examples"] = "Exemples"
  949. Locale["fr"]["see-also"] = "Voir aussi"
  950. Locale["fr"]["family"] = "Indo-European"
  951. Locale["fr"]["iso"] = "fra"
  952. Locale["fr"]["glotto"] = "stan1290"
  953. Locale["fr"]["script"] = "Latn"
  954. Locale["fr"]["dictionary"] = "true"
  955. Locale["gl"]["name"] = "Galician"
  956. Locale["gl"]["endonym"] = "Galego"
  957. Locale["gl"]["translations-of"] = "Traducións de %s"
  958. Locale["gl"]["definitions-of"] = "Definicións de %s"
  959. Locale["gl"]["synonyms"] = "Sinónimos"
  960. Locale["gl"]["examples"] = "Exemplos"
  961. Locale["gl"]["see-also"] = "Ver tamén"
  962. Locale["gl"]["family"] = "Indo-European"
  963. Locale["gl"]["iso"] = "glg"
  964. Locale["gl"]["glotto"] = "gali1258"
  965. Locale["gl"]["script"] = "Latn"
  966. Locale["ka"]["name"] = "Georgian"
  967. Locale["ka"]["endonym"] = "ქართული"
  968. Locale["ka"]["translations-of"] = "%s-ის თარგმანები"
  969. Locale["ka"]["definitions-of"] = "%s-ის განსაზღვრებები"
  970. Locale["ka"]["synonyms"] = "სინონიმები"
  971. Locale["ka"]["examples"] = "მაგალითები"
  972. Locale["ka"]["see-also"] = "ასევე იხილეთ"
  973. Locale["ka"]["family"] = "Kartvelian"
  974. Locale["ka"]["iso"] = "kat"
  975. Locale["ka"]["glotto"] = "nucl1302"
  976. Locale["ka"]["script"] = "Geor"
  977. Locale["de"]["name"] = "German"
  978. Locale["de"]["endonym"] = "Deutsch"
  979. Locale["de"]["translations-of"] = "Übersetzungen für %s"
  980. Locale["de"]["definitions-of"] = "Definitionen von %s"
  981. Locale["de"]["synonyms"] = "Synonyme"
  982. Locale["de"]["examples"] = "Beispiele"
  983. Locale["de"]["see-also"] = "Siehe auch"
  984. Locale["de"]["family"] = "Indo-European"
  985. Locale["de"]["iso"] = "deu"
  986. Locale["de"]["glotto"] = "stan1295"
  987. Locale["de"]["script"] = "Latn"
  988. Locale["de"]["dictionary"] = "true"
  989. Locale["el"]["name"] = "Greek"
  990. Locale["el"]["endonym"] = "Ελληνικά"
  991. Locale["el"]["translations-of"] = "Μεταφράσεις του %s"
  992. Locale["el"]["definitions-of"] = "Όρισμοί %s"
  993. Locale["el"]["synonyms"] = "Συνώνυμα"
  994. Locale["el"]["examples"] = "Παραδείγματα"
  995. Locale["el"]["see-also"] = "Δείτε επίσης"
  996. Locale["el"]["family"] = "Indo-European"
  997. Locale["el"]["iso"] = "ell"
  998. Locale["el"]["glotto"] = "mode1248"
  999. Locale["el"]["script"] = "Grek"
  1000. Locale["gu"]["name"] = "Gujarati"
  1001. Locale["gu"]["endonym"] = "ગુજરાતી"
  1002. Locale["gu"]["translations-of"] = "%s ના અનુવાદ"
  1003. Locale["gu"]["definitions-of"] = "%s ની વ્યાખ્યાઓ"
  1004. Locale["gu"]["synonyms"] = "સમાનાર્થી"
  1005. Locale["gu"]["examples"] = "ઉદાહરણો"
  1006. Locale["gu"]["see-also"] = "આ પણ જુઓ"
  1007. Locale["gu"]["family"] = "Indo-European"
  1008. Locale["gu"]["iso"] = "guj"
  1009. Locale["gu"]["glotto"] = "guja1252"
  1010. Locale["gu"]["script"] = "Gujr"
  1011. Locale["ht"]["name"] = "Haitian Creole"
  1012. Locale["ht"]["endonym"] = "Kreyòl Ayisyen"
  1013. Locale["ht"]["translations-of"] = "Tradiksyon %s"
  1014. Locale["ht"]["definitions-of"] = "Definisyon nan %s"
  1015. Locale["ht"]["synonyms"] = "Sinonim"
  1016. Locale["ht"]["examples"] = "Egzanp:"
  1017. Locale["ht"]["see-also"] = "Wè tou"
  1018. Locale["ht"]["family"] = "Indo-European"
  1019. Locale["ht"]["iso"] = "hat"
  1020. Locale["ht"]["glotto"] = "hait1244"
  1021. Locale["ht"]["script"] = "Latn"
  1022. Locale["haw"]["name"] = "Hawaiian"
  1023. Locale["haw"]["endonym"] = "ʻŌlelo Hawaiʻi"
  1024. Locale["haw"]["family"] = "Austronesian"
  1025. Locale["haw"]["iso"] = "haw"
  1026. Locale["haw"]["glotto"] = "hawa1245"
  1027. Locale["haw"]["script"] = "Latn"
  1028. Locale["ha"]["name"] = "Hausa"
  1029. Locale["ha"]["endonym"] = "Hausa"
  1030. Locale["ha"]["translations-of"] = "Fassarar %s"
  1031. Locale["ha"]["definitions-of"] = "Ma'anoni na %s"
  1032. Locale["ha"]["synonyms"] = "Masu kamancin ma'ana"
  1033. Locale["ha"]["examples"] = "Misalai"
  1034. Locale["ha"]["see-also"] = "Duba kuma"
  1035. Locale["ha"]["family"] = "Afro-Asiatic"
  1036. Locale["ha"]["iso"] = "hau"
  1037. Locale["ha"]["glotto"] = "haus1257"
  1038. Locale["ha"]["script"] = "Latn"
  1039. Locale["he"]["name"] = "Hebrew"
  1040. Locale["he"]["endonym"] = "עִבְרִית"
  1041. Locale["he"]["translations-of"] = "תרגומים של %s"
  1042. Locale["he"]["definitions-of"] = "הגדרות של %s"
  1043. Locale["he"]["synonyms"] = "מילים נרדפות"
  1044. Locale["he"]["examples"] = "דוגמאות"
  1045. Locale["he"]["see-also"] = "ראה גם"
  1046. Locale["he"]["family"] = "Afro-Asiatic"
  1047. Locale["he"]["iso"] = "heb"
  1048. Locale["he"]["glotto"] = "hebr1245"
  1049. Locale["he"]["script"] = "Hebr"
  1050. Locale["he"]["rtl"] = "true"
  1051. Locale["hi"]["name"] = "Hindi"
  1052. Locale["hi"]["endonym"] = "हिन्दी"
  1053. Locale["hi"]["translations-of"] = "%s के अनुवाद"
  1054. Locale["hi"]["definitions-of"] = "%s की परिभाषाएं"
  1055. Locale["hi"]["synonyms"] = "समानार्थी"
  1056. Locale["hi"]["examples"] = "उदाहरण"
  1057. Locale["hi"]["see-also"] = "यह भी देखें"
  1058. Locale["hi"]["family"] = "Indo-European"
  1059. Locale["hi"]["iso"] = "hin"
  1060. Locale["hi"]["glotto"] = "hind1269"
  1061. Locale["hi"]["script"] = "Deva"
  1062. Locale["hmn"]["name"] = "Hmong"
  1063. Locale["hmn"]["endonym"] = "Hmoob"
  1064. Locale["hmn"]["translations-of"] = "Lus txhais: %s"
  1065. Locale["hmn"]["family"] = "Hmong-Mien"
  1066. Locale["hmn"]["iso"] = "hmn"
  1067. Locale["hmn"]["glotto"] = "firs1234"
  1068. Locale["hmn"]["script"] = "Latn"
  1069. Locale["hu"]["name"] = "Hungarian"
  1070. Locale["hu"]["endonym"] = "Magyar"
  1071. Locale["hu"]["translations-of"] = "%s fordításai"
  1072. Locale["hu"]["definitions-of"] = "%s jelentései"
  1073. Locale["hu"]["synonyms"] = "Szinonimák"
  1074. Locale["hu"]["examples"] = "Példák"
  1075. Locale["hu"]["see-also"] = "Lásd még"
  1076. Locale["hu"]["family"] = "Uralic"
  1077. Locale["hu"]["iso"] = "hun"
  1078. Locale["hu"]["glotto"] = "hung1274"
  1079. Locale["hu"]["script"] = "Latn"
  1080. Locale["is"]["name"] = "Icelandic"
  1081. Locale["is"]["endonym"] = "Íslenska"
  1082. Locale["is"]["translations-of"] = "Þýðingar á %s"
  1083. Locale["is"]["definitions-of"] = "Skilgreiningar á"
  1084. Locale["is"]["synonyms"] = "Samheiti"
  1085. Locale["is"]["examples"] = "Dæmi"
  1086. Locale["is"]["see-also"] = "Sjá einnig"
  1087. Locale["is"]["family"] = "Indo-European"
  1088. Locale["is"]["iso"] = "isl"
  1089. Locale["is"]["glotto"] = "icel1247"
  1090. Locale["is"]["script"] = "Latn"
  1091. Locale["ig"]["name"] = "Igbo"
  1092. Locale["ig"]["endonym"] = "Igbo"
  1093. Locale["ig"]["translations-of"] = "Ntụgharị asụsụ nke %s"
  1094. Locale["ig"]["definitions-of"] = "Nkọwapụta nke %s"
  1095. Locale["ig"]["synonyms"] = "Okwu oyiri"
  1096. Locale["ig"]["examples"] = "Ọmụmaatụ"
  1097. Locale["ig"]["see-also"] = "Hụkwuo"
  1098. Locale["ig"]["family"] = "Atlantic-Congo"
  1099. Locale["ig"]["iso"] = "ibo"
  1100. Locale["ig"]["glotto"] = "nucl1417"
  1101. Locale["ig"]["script"] = "Latn"
  1102. Locale["id"]["name"] = "Indonesian"
  1103. Locale["id"]["endonym"] = "Bahasa Indonesia"
  1104. Locale["id"]["translations-of"] = "Terjemahan dari %s"
  1105. Locale["id"]["definitions-of"] = "Definisi %s"
  1106. Locale["id"]["synonyms"] = "Sinonim"
  1107. Locale["id"]["examples"] = "Contoh"
  1108. Locale["id"]["see-also"] = "Lihat juga"
  1109. Locale["id"]["family"] = "Austronesian"
  1110. Locale["id"]["iso"] = "ind"
  1111. Locale["id"]["glotto"] = "indo1316"
  1112. Locale["id"]["script"] = "Latn"
  1113. Locale["ga"]["name"] = "Irish"
  1114. Locale["ga"]["endonym"] = "Gaeilge"
  1115. Locale["ga"]["translations-of"] = "Aistriúcháin ar %s"
  1116. Locale["ga"]["definitions-of"] = "Sainmhínithe ar %s"
  1117. Locale["ga"]["synonyms"] = "Comhchiallaigh"
  1118. Locale["ga"]["examples"] = "Samplaí"
  1119. Locale["ga"]["see-also"] = "féach freisin"
  1120. Locale["ga"]["family"] = "Indo-European"
  1121. Locale["ga"]["iso"] = "gle"
  1122. Locale["ga"]["glotto"] = "iris1253"
  1123. Locale["ga"]["script"] = "Latn"
  1124. Locale["it"]["name"] = "Italian"
  1125. Locale["it"]["endonym"] = "Italiano"
  1126. Locale["it"]["translations-of"] = "Traduzioni di %s"
  1127. Locale["it"]["definitions-of"] = "Definizioni di %s"
  1128. Locale["it"]["synonyms"] = "Sinonimi"
  1129. Locale["it"]["examples"] = "Esempi"
  1130. Locale["it"]["see-also"] = "Vedi anche"
  1131. Locale["it"]["family"] = "Indo-European"
  1132. Locale["it"]["iso"] = "ita"
  1133. Locale["it"]["glotto"] = "ital1282"
  1134. Locale["it"]["script"] = "Latn"
  1135. Locale["it"]["dictionary"] = "true"
  1136. Locale["ja"]["name"] = "Japanese"
  1137. Locale["ja"]["endonym"] = "日本語"
  1138. Locale["ja"]["translations-of"] = "「%s」の翻訳"
  1139. Locale["ja"]["definitions-of"] = "%s の定義"
  1140. Locale["ja"]["synonyms"] = "同義語"
  1141. Locale["ja"]["examples"] = "例"
  1142. Locale["ja"]["see-also"] = "関連項目"
  1143. Locale["ja"]["family"] = "Japonic"
  1144. Locale["ja"]["iso"] = "jpn"
  1145. Locale["ja"]["glotto"] = "nucl1643"
  1146. Locale["ja"]["script"] = "Jpan"
  1147. Locale["ja"]["dictionary"] = "true"
  1148. Locale["jv"]["name"] = "Javanese"
  1149. Locale["jv"]["endonym"] = "Basa Jawa"
  1150. Locale["jv"]["translations-of"] = "Terjemahan %s"
  1151. Locale["jv"]["definitions-of"] = "Arti %s"
  1152. Locale["jv"]["synonyms"] = "Sinonim"
  1153. Locale["jv"]["examples"] = "Conto"
  1154. Locale["jv"]["see-also"] = "Deleng uga"
  1155. Locale["jv"]["family"] = "Austronesian"
  1156. Locale["jv"]["iso"] = "jav"
  1157. Locale["jv"]["glotto"] = "java1254"
  1158. Locale["jv"]["script"] = "Latn"
  1159. Locale["kn"]["name"] = "Kannada"
  1160. Locale["kn"]["endonym"] = "ಕನ್ನಡ"
  1161. Locale["kn"]["translations-of"] = "%s ನ ಅನುವಾದಗಳು"
  1162. Locale["kn"]["definitions-of"] = "%s ನ ವ್ಯಾಖ್ಯಾನಗಳು"
  1163. Locale["kn"]["synonyms"] = "ಸಮಾನಾರ್ಥಕಗಳು"
  1164. Locale["kn"]["examples"] = "ಉದಾಹರಣೆಗಳು"
  1165. Locale["kn"]["see-also"] = "ಇದನ್ನೂ ಗಮನಿಸಿ"
  1166. Locale["kn"]["family"] = "Dravidian"
  1167. Locale["kn"]["iso"] = "kan"
  1168. Locale["kn"]["glotto"] = "nucl1305"
  1169. Locale["kn"]["script"] = "Knda"
  1170. Locale["kk"]["name"] = "Kazakh"
  1171. Locale["kk"]["endonym"] = "Қазақ тілі"
  1172. Locale["kk"]["translations-of"] = "%s аудармалары"
  1173. Locale["kk"]["definitions-of"] = "%s анықтамалары"
  1174. Locale["kk"]["synonyms"] = "Синонимдер"
  1175. Locale["kk"]["examples"] = "Мысалдар"
  1176. Locale["kk"]["see-also"] = "Келесі тізімді де көріңіз:"
  1177. Locale["kk"]["family"] = "Turkic"
  1178. Locale["kk"]["iso"] = "kaz"
  1179. Locale["kk"]["glotto"] = "kaza1248"
  1180. Locale["kk"]["script"] = "Cyrl"
  1181. Locale["km"]["name"] = "Khmer"
  1182. Locale["km"]["endonym"] = "ភាសាខ្មែរ"
  1183. Locale["km"]["translations-of"] = "ការ​បក​ប្រែ​នៃ %s"
  1184. Locale["km"]["definitions-of"] = "និយមន័យ​នៃ​ %s"
  1185. Locale["km"]["synonyms"] = "សទិសន័យ"
  1186. Locale["km"]["examples"] = "ឧទាហរណ៍"
  1187. Locale["km"]["see-also"] = "មើល​ផង​ដែរ"
  1188. Locale["km"]["family"] = "Austroasiatic"
  1189. Locale["km"]["iso"] = "khm"
  1190. Locale["km"]["glotto"] = "cent1989"
  1191. Locale["km"]["script"] = "Khmr"
  1192. Locale["ko"]["name"] = "Korean"
  1193. Locale["ko"]["endonym"] = "한국어"
  1194. Locale["ko"]["translations-of"] = "%s의 번역"
  1195. Locale["ko"]["definitions-of"] = "%s의 정의"
  1196. Locale["ko"]["synonyms"] = "동의어"
  1197. Locale["ko"]["examples"] = "예문"
  1198. Locale["ko"]["see-also"] = "참조"
  1199. Locale["ko"]["family"] = "Koreanic"
  1200. Locale["ko"]["iso"] = "kor"
  1201. Locale["ko"]["glotto"] = "kore1280"
  1202. Locale["ko"]["script"] = "Kore"
  1203. Locale["ko"]["dictionary"] = "true"
  1204. Locale["ku"]["name"] = "Kurdish"
  1205. Locale["ku"]["endonym"] = "Kurdî"
  1206. Locale["ku"]["family"] = "Indo-European"
  1207. Locale["ku"]["iso"] = "kur"
  1208. Locale["ku"]["glotto"] = "kurd1259"
  1209. Locale["ku"]["script"] = "Latn"
  1210. Locale["ky"]["name"] = "Kyrgyz"
  1211. Locale["ky"]["endonym"] = "Кыргызча"
  1212. Locale["ky"]["translations-of"] = "%s котормосу"
  1213. Locale["ky"]["definitions-of"] = "%s аныктамасы"
  1214. Locale["ky"]["synonyms"] = "Синонимдер"
  1215. Locale["ky"]["examples"] = "Мисалдар"
  1216. Locale["ky"]["see-also"] = "Дагы караңыз"
  1217. Locale["ky"]["family"] = "Turkic"
  1218. Locale["ky"]["iso"] = "kir"
  1219. Locale["ky"]["glotto"] = "kirg1245"
  1220. Locale["ky"]["script"] = "Cyrl"
  1221. Locale["lo"]["name"] = "Lao"
  1222. Locale["lo"]["endonym"] = "ລາວ"
  1223. Locale["lo"]["translations-of"] = "ຄຳ​ແປ​ສຳລັບ %s"
  1224. Locale["lo"]["definitions-of"] = "ຄວາມໝາຍຂອງ %s"
  1225. Locale["lo"]["synonyms"] = "ຄຳທີ່ຄ້າຍກັນ %s"
  1226. Locale["lo"]["examples"] = "ຕົວຢ່າງ"
  1227. Locale["lo"]["see-also"] = "ເບິ່ງ​ເພີ່ມ​ເຕີມ"
  1228. Locale["lo"]["family"] = "Tai-Kadai"
  1229. Locale["lo"]["iso"] = "lao"
  1230. Locale["lo"]["glotto"] = "laoo1244"
  1231. Locale["lo"]["script"] = "Laoo"
  1232. Locale["la"]["name"] = "Latin"
  1233. Locale["la"]["endonym"] = "Latina"
  1234. Locale["la"]["translations-of"] = "Versio de %s"
  1235. Locale["la"]["family"] = "Indo-European"
  1236. Locale["la"]["iso"] = "lat"
  1237. Locale["la"]["glotto"] = "lati1261"
  1238. Locale["la"]["script"] = "Latn"
  1239. Locale["lv"]["name"] = "Latvian"
  1240. Locale["lv"]["endonym"] = "Latviešu"
  1241. Locale["lv"]["translations-of"] = "%s tulkojumi"
  1242. Locale["lv"]["definitions-of"] = "%s definīcijas"
  1243. Locale["lv"]["synonyms"] = "Sinonīmi"
  1244. Locale["lv"]["examples"] = "Piemēri"
  1245. Locale["lv"]["see-also"] = "Skatiet arī"
  1246. Locale["lv"]["family"] = "Indo-European"
  1247. Locale["lv"]["iso"] = "lav"
  1248. Locale["lv"]["glotto"] = "latv1249"
  1249. Locale["lv"]["script"] = "Latn"
  1250. Locale["lt"]["name"] = "Lithuanian"
  1251. Locale["lt"]["endonym"] = "Lietuvių"
  1252. Locale["lt"]["translations-of"] = "„%s“ vertimai"
  1253. Locale["lt"]["definitions-of"] = "„%s“ apibrėžimai"
  1254. Locale["lt"]["synonyms"] = "Sinonimai"
  1255. Locale["lt"]["examples"] = "Pavyzdžiai"
  1256. Locale["lt"]["see-also"] = "Taip pat žiūrėkite"
  1257. Locale["lt"]["family"] = "Indo-European"
  1258. Locale["lt"]["iso"] = "lit"
  1259. Locale["lt"]["glotto"] = "lith1251"
  1260. Locale["lt"]["script"] = "Latn"
  1261. Locale["lb"]["name"] = "Luxembourgish"
  1262. Locale["lb"]["endonym"] = "Lëtzebuergesch"
  1263. Locale["lb"]["family"] = "Indo-European"
  1264. Locale["lb"]["iso"] = "ltz"
  1265. Locale["lb"]["glotto"] = "luxe1241"
  1266. Locale["lb"]["script"] = "Latn"
  1267. Locale["mk"]["name"] = "Macedonian"
  1268. Locale["mk"]["endonym"] = "Македонски"
  1269. Locale["mk"]["translations-of"] = "Преводи на %s"
  1270. Locale["mk"]["definitions-of"] = "Дефиниции на %s"
  1271. Locale["mk"]["synonyms"] = "Синоними"
  1272. Locale["mk"]["examples"] = "Примери"
  1273. Locale["mk"]["see-also"] = "Види и"
  1274. Locale["mk"]["family"] = "Indo-European"
  1275. Locale["mk"]["iso"] = "mkd"
  1276. Locale["mk"]["glotto"] = "mace1250"
  1277. Locale["mk"]["script"] = "Cyrl"
  1278. Locale["mg"]["name"] = "Malagasy"
  1279. Locale["mg"]["endonym"] = "Malagasy"
  1280. Locale["mg"]["translations-of"] = "Dikan'ny %s"
  1281. Locale["mg"]["definitions-of"] = "Famaritana ny %s"
  1282. Locale["mg"]["synonyms"] = "Mitovy hevitra"
  1283. Locale["mg"]["examples"] = "Ohatra"
  1284. Locale["mg"]["see-also"] = "Jereo ihany koa"
  1285. Locale["mg"]["family"] = "Austronesian"
  1286. Locale["mg"]["iso"] = "mlg"
  1287. Locale["mg"]["glotto"] = "plat1254"
  1288. Locale["mg"]["script"] = "Latn"
  1289. Locale["ms"]["name"] = "Malay"
  1290. Locale["ms"]["endonym"] = "Bahasa Melayu"
  1291. Locale["ms"]["translations-of"] = "Terjemahan %s"
  1292. Locale["ms"]["definitions-of"] = "Takrif %s"
  1293. Locale["ms"]["synonyms"] = "Sinonim"
  1294. Locale["ms"]["examples"] = "Contoh"
  1295. Locale["ms"]["see-also"] = "Lihat juga"
  1296. Locale["ms"]["family"] = "Austronesian"
  1297. Locale["ms"]["iso"] = "msa"
  1298. Locale["ms"]["glotto"] = "stan1306"
  1299. Locale["ms"]["script"] = "Latn"
  1300. Locale["ml"]["name"] = "Malayalam"
  1301. Locale["ml"]["endonym"] = "മലയാളം"
  1302. Locale["ml"]["translations-of"] = "%s എന്നതിന്റെ വിവർത്തനങ്ങൾ"
  1303. Locale["ml"]["definitions-of"] = "%s എന്നതിന്റെ നിർവ്വചനങ്ങൾ"
  1304. Locale["ml"]["synonyms"] = "പര്യായങ്ങള്‍"
  1305. Locale["ml"]["examples"] = "ഉദാഹരണങ്ങള്‍"
  1306. Locale["ml"]["see-also"] = "ഇതും കാണുക"
  1307. Locale["ml"]["family"] = "Dravidian"
  1308. Locale["ml"]["iso"] = "mal"
  1309. Locale["ml"]["glotto"] = "mala1464"
  1310. Locale["ml"]["script"] = "Mlym"
  1311. Locale["mt"]["name"] = "Maltese"
  1312. Locale["mt"]["endonym"] = "Malti"
  1313. Locale["mt"]["translations-of"] = "Traduzzjonijiet ta' %s"
  1314. Locale["mt"]["definitions-of"] = "Definizzjonijiet ta' %s"
  1315. Locale["mt"]["synonyms"] = "Sinonimi"
  1316. Locale["mt"]["examples"] = "Eżempji"
  1317. Locale["mt"]["see-also"] = "Ara wkoll"
  1318. Locale["mt"]["family"] = "Afro-Asiatic"
  1319. Locale["mt"]["iso"] = "mlt"
  1320. Locale["mt"]["glotto"] = "malt1254"
  1321. Locale["mt"]["script"] = "Latn"
  1322. Locale["mi"]["name"] = "Maori"
  1323. Locale["mi"]["endonym"] = "Māori"
  1324. Locale["mi"]["translations-of"] = "Ngā whakamāoritanga o %s"
  1325. Locale["mi"]["definitions-of"] = "Ngā whakamārama o %s"
  1326. Locale["mi"]["synonyms"] = "Ngā Kupu Taurite"
  1327. Locale["mi"]["examples"] = "Ngā Tauira:"
  1328. Locale["mi"]["see-also"] = "Tiro hoki:"
  1329. Locale["mi"]["family"] = "Austronesian"
  1330. Locale["mi"]["iso"] = "mri"
  1331. Locale["mi"]["glotto"] = "maor1246"
  1332. Locale["mi"]["script"] = "Latn"
  1333. Locale["mr"]["name"] = "Marathi"
  1334. Locale["mr"]["endonym"] = "मराठी"
  1335. Locale["mr"]["translations-of"] = "%s ची भाषांतरे"
  1336. Locale["mr"]["definitions-of"] = "%s च्या व्याख्या"
  1337. Locale["mr"]["synonyms"] = "समानार्थी शब्द"
  1338. Locale["mr"]["examples"] = "उदाहरणे"
  1339. Locale["mr"]["see-also"] = "हे देखील पहा"
  1340. Locale["mr"]["family"] = "Indo-European"
  1341. Locale["mr"]["iso"] = "mar"
  1342. Locale["mr"]["glotto"] = "mara1378"
  1343. Locale["mr"]["script"] = "Deva"
  1344. Locale["mn"]["name"] = "Mongolian"
  1345. Locale["mn"]["endonym"] = "Монгол"
  1346. Locale["mn"]["translations-of"] = "%s-н орчуулга"
  1347. Locale["mn"]["definitions-of"] = "%s үгийн тодорхойлолт"
  1348. Locale["mn"]["synonyms"] = "Ойролцоо утгатай"
  1349. Locale["mn"]["examples"] = "Жишээнүүд"
  1350. Locale["mn"]["see-also"] = "Мөн харах"
  1351. Locale["mn"]["family"] = "Mongolic"
  1352. Locale["mn"]["iso"] = "mon"
  1353. Locale["mn"]["glotto"] = "mong1331"
  1354. Locale["mn"]["script"] = "Cyrl"
  1355. Locale["my"]["name"] = "Myanmar"
  1356. Locale["my"]["endonym"] = "မြန်မာစာ"
  1357. Locale["my"]["translations-of"] = "%s၏ ဘာသာပြန်ဆိုချက်များ"
  1358. Locale["my"]["definitions-of"] = "%s၏ အနက်ဖွင့်ဆိုချက်များ"
  1359. Locale["my"]["synonyms"] = "ကြောင်းတူသံကွဲများ"
  1360. Locale["my"]["examples"] = "ဥပမာ"
  1361. Locale["my"]["see-also"] = "ဖော်ပြပါများကိုလဲ ကြည့်ပါ"
  1362. Locale["my"]["family"] = "Sino-Tibetan"
  1363. Locale["my"]["iso"] = "mya"
  1364. Locale["my"]["glotto"] = "nucl1310"
  1365. Locale["my"]["script"] = "Mymr"
  1366. Locale["ne"]["name"] = "Nepali"
  1367. Locale["ne"]["endonym"] = "नेपाली"
  1368. Locale["ne"]["translations-of"] = "%sका अनुवाद"
  1369. Locale["ne"]["definitions-of"] = "%sको परिभाषा"
  1370. Locale["ne"]["synonyms"] = "समानार्थीहरू"
  1371. Locale["ne"]["examples"] = "उदाहरणहरु"
  1372. Locale["ne"]["see-also"] = "यो पनि हेर्नुहोस्"
  1373. Locale["ne"]["family"] = "Indo-European"
  1374. Locale["ne"]["iso"] = "nep"
  1375. Locale["ne"]["glotto"] = "nepa1254"
  1376. Locale["ne"]["script"] = "Deva"
  1377. Locale["no"]["name"] = "Norwegian"
  1378. Locale["no"]["endonym"] = "Norsk"
  1379. Locale["no"]["translations-of"] = "Oversettelser av %s"
  1380. Locale["no"]["definitions-of"] = "Definisjoner av %s"
  1381. Locale["no"]["synonyms"] = "Synonymer"
  1382. Locale["no"]["examples"] = "Eksempler"
  1383. Locale["no"]["see-also"] = "Se også"
  1384. Locale["no"]["family"] = "Indo-European"
  1385. Locale["no"]["iso"] = "nor"
  1386. Locale["no"]["glotto"] = "norw1258"
  1387. Locale["no"]["script"] = "Latn"
  1388. Locale["ps"]["name"] = "Pashto"
  1389. Locale["ps"]["endonym"] = "پښتو"
  1390. Locale["ps"]["translations-of"] = "د %sژباړې"
  1391. Locale["ps"]["definitions-of"] = "د%s تعریفونه"
  1392. Locale["ps"]["synonyms"] = "مترادف لغتونه"
  1393. Locale["ps"]["examples"] = "بېلګې"
  1394. Locale["ps"]["see-also"] = "دا هم ووینئ"
  1395. Locale["ps"]["family"] = "Indo-European"
  1396. Locale["ps"]["iso"] = "pus"
  1397. Locale["ps"]["glotto"] = "pash1269"
  1398. Locale["ps"]["script"] = "Arab"
  1399. Locale["ps"]["rtl"] = "true"
  1400. Locale["fa"]["name"] = "Persian"
  1401. Locale["fa"]["endonym"] = "فارسی"
  1402. Locale["fa"]["translations-of"] = "ترجمه‌های %s"
  1403. Locale["fa"]["definitions-of"] = "تعریف‌های %s"
  1404. Locale["fa"]["synonyms"] = "مترادف‌ها"
  1405. Locale["fa"]["examples"] = "مثال‌ها"
  1406. Locale["fa"]["see-also"] = "همچنین مراجعه کنید به"
  1407. Locale["fa"]["family"] = "Indo-European"
  1408. Locale["fa"]["iso"] = "fas"
  1409. Locale["fa"]["glotto"] = "west2369"
  1410. Locale["fa"]["script"] = "Arab"
  1411. Locale["fa"]["rtl"] = "true"
  1412. Locale["pl"]["name"] = "Polish"
  1413. Locale["pl"]["endonym"] = "Polski"
  1414. Locale["pl"]["translations-of"] = "Tłumaczenia %s"
  1415. Locale["pl"]["definitions-of"] = "%s – definicje"
  1416. Locale["pl"]["synonyms"] = "Synonimy"
  1417. Locale["pl"]["examples"] = "Przykłady"
  1418. Locale["pl"]["see-also"] = "Zobacz też"
  1419. Locale["pl"]["family"] = "Indo-European"
  1420. Locale["pl"]["iso"] = "pol"
  1421. Locale["pl"]["glotto"] = "poli1260"
  1422. Locale["pl"]["script"] = "Latn"
  1423. Locale["pt"]["name"] = "Portuguese"
  1424. Locale["pt"]["endonym"] = "Português"
  1425. Locale["pt"]["translations-of"] = "Traduções de %s"
  1426. Locale["pt"]["definitions-of"] = "Definições de %s"
  1427. Locale["pt"]["synonyms"] = "Sinônimos"
  1428. Locale["pt"]["examples"] = "Exemplos"
  1429. Locale["pt"]["see-also"] = "Veja também"
  1430. Locale["pt"]["family"] = "Indo-European"
  1431. Locale["pt"]["iso"] = "por"
  1432. Locale["pt"]["glotto"] = "port1283"
  1433. Locale["pt"]["script"] = "Latn"
  1434. Locale["pt"]["dictionary"] = "true"
  1435. Locale["pa"]["name"] = "Punjabi"
  1436. Locale["pa"]["endonym"] = "ਪੰਜਾਬੀ"
  1437. Locale["pa"]["translations-of"] = "ਦੇ ਅਨੁਵਾਦ%s"
  1438. Locale["pa"]["definitions-of"] = "ਦੀਆਂ ਪਰਿਭਾਸ਼ਾ %s"
  1439. Locale["pa"]["synonyms"] = "ਸਮਾਨਾਰਥਕ ਸ਼ਬਦ"
  1440. Locale["pa"]["examples"] = "ਉਦਾਹਰਣਾਂ"
  1441. Locale["pa"]["see-also"] = "ਇਹ ਵੀ ਵੇਖੋ"
  1442. Locale["pa"]["family"] = "Indo-European"
  1443. Locale["pa"]["iso"] = "pan"
  1444. Locale["pa"]["glotto"] = "panj1256"
  1445. Locale["pa"]["script"] = "Guru"
  1446. Locale["ro"]["name"] = "Romanian"
  1447. Locale["ro"]["endonym"] = "Română"
  1448. Locale["ro"]["translations-of"] = "Traduceri pentru %s"
  1449. Locale["ro"]["definitions-of"] = "Definiții pentru %s"
  1450. Locale["ro"]["synonyms"] = "Sinonime"
  1451. Locale["ro"]["examples"] = "Exemple"
  1452. Locale["ro"]["see-also"] = "Vedeți și"
  1453. Locale["ro"]["family"] = "Indo-European"
  1454. Locale["ro"]["iso"] = "ron"
  1455. Locale["ro"]["glotto"] = "roma1327"
  1456. Locale["ro"]["script"] = "Latn"
  1457. Locale["ru"]["name"] = "Russian"
  1458. Locale["ru"]["endonym"] = "Русский"
  1459. Locale["ru"]["translations-of"] = "%s: варианты перевода"
  1460. Locale["ru"]["definitions-of"] = "%s – определения"
  1461. Locale["ru"]["synonyms"] = "Синонимы"
  1462. Locale["ru"]["examples"] = "Примеры"
  1463. Locale["ru"]["see-also"] = "Похожие слова"
  1464. Locale["ru"]["family"] = "Indo-European"
  1465. Locale["ru"]["iso"] = "rus"
  1466. Locale["ru"]["glotto"] = "russ1263"
  1467. Locale["ru"]["script"] = "Cyrl"
  1468. Locale["ru"]["dictionary"] = "true"
  1469. Locale["sm"]["name"] = "Samoan"
  1470. Locale["sm"]["endonym"] = "Gagana Sāmoa"
  1471. Locale["sm"]["family"] = "Austronesian"
  1472. Locale["sm"]["iso"] = "smo"
  1473. Locale["sm"]["glotto"] = "samo1305"
  1474. Locale["sm"]["script"] = "Latn"
  1475. Locale["gd"]["name"] = "Scots Gaelic"
  1476. Locale["gd"]["endonym"] = "Gàidhlig"
  1477. Locale["gd"]["translations-of"] = "Eadar-theangachadh airson %s"
  1478. Locale["gd"]["definitions-of"] = "Deifiniseanan airson %s"
  1479. Locale["gd"]["synonyms"] = "Co-fhaclan"
  1480. Locale["gd"]["examples"] = "Buill-eisimpleir"
  1481. Locale["gd"]["see-also"] = "Faic na leanas cuideachd"
  1482. Locale["gd"]["family"] = "Indo-European"
  1483. Locale["gd"]["iso"] = "gla"
  1484. Locale["gd"]["glotto"] = "scot1245"
  1485. Locale["gd"]["script"] = "Latn"
  1486. Locale["sr-Cyrl"]["name"] = "Serbian (Cyrillic)"
  1487. Locale["sr-Cyrl"]["endonym"] = "српски"
  1488. Locale["sr-Cyrl"]["translations-of"] = "Преводи за „%s“"
  1489. Locale["sr-Cyrl"]["definitions-of"] = "Дефиниције за %s"
  1490. Locale["sr-Cyrl"]["synonyms"] = "Синоними"
  1491. Locale["sr-Cyrl"]["examples"] = "Примери"
  1492. Locale["sr-Cyrl"]["see-also"] = "Погледајте такође"
  1493. Locale["sr-Cyrl"]["family"] = "Indo-European"
  1494. Locale["sr-Cyrl"]["iso"] = "srp-Cyrl"
  1495. Locale["sr-Cyrl"]["glotto"] = "serb1264"
  1496. Locale["sr-Cyrl"]["script"] = "Cyrl"
  1497. Locale["sr-Latn"]["name"] = "Serbian (Latin)"
  1498. Locale["sr-Latn"]["endonym"] = "srpski"
  1499. Locale["sr-Latn"]["translations-of"] = "Prevodi za „%s“"
  1500. Locale["sr-Latn"]["definitions-of"] = "Definicije za %s"
  1501. Locale["sr-Latn"]["synonyms"] = "Sinonimi"
  1502. Locale["sr-Latn"]["examples"] = "Primeri"
  1503. Locale["sr-Latn"]["see-also"] = "Pogledajte takođe"
  1504. Locale["sr-Latn"]["family"] = "Indo-European"
  1505. Locale["sr-Latn"]["iso"] = "srp-Latn"
  1506. Locale["sr-Latn"]["glotto"] = "serb1264"
  1507. Locale["sr-Latn"]["script"] = "Latn"
  1508. Locale["st"]["name"] = "Sesotho"
  1509. Locale["st"]["endonym"] = "Sesotho"
  1510. Locale["st"]["translations-of"] = "Liphetolelo tsa %s"
  1511. Locale["st"]["definitions-of"] = "Meelelo ea %s"
  1512. Locale["st"]["synonyms"] = "Mantsoe a tšoanang ka moelelo"
  1513. Locale["st"]["examples"] = "Mehlala"
  1514. Locale["st"]["see-also"] = "Bona hape"
  1515. Locale["st"]["family"] = "Atlantic-Congo"
  1516. Locale["st"]["iso"] = "sot"
  1517. Locale["st"]["glotto"] = "sout2807"
  1518. Locale["st"]["script"] = "Latn"
  1519. Locale["sn"]["name"] = "Shona"
  1520. Locale["sn"]["endonym"] = "chiShona"
  1521. Locale["sn"]["translations-of"] = "Shanduro dze %s"
  1522. Locale["sn"]["definitions-of"] = "Zvinoreva %s"
  1523. Locale["sn"]["synonyms"] = "Mashoko anoreva zvakafana nemamwe"
  1524. Locale["sn"]["examples"] = "Mienzaniso"
  1525. Locale["sn"]["see-also"] = "Onawo"
  1526. Locale["sn"]["family"] = "Atlantic-Congo"
  1527. Locale["sn"]["iso"] = "sna"
  1528. Locale["sn"]["glotto"] = "core1255"
  1529. Locale["sn"]["script"] = "Latn"
  1530. Locale["sd"]["name"] = "Sindhi"
  1531. Locale["sd"]["endonym"] = "سنڌي"
  1532. Locale["sd"]["translations-of"] = "%s جو ترجمو"
  1533. Locale["sd"]["definitions-of"] = "%s جون وصفون"
  1534. Locale["sd"]["synonyms"] = "هم معني"
  1535. Locale["sd"]["examples"] = "مثالون"
  1536. Locale["sd"]["see-also"] = "به ڏسو"
  1537. Locale["sd"]["family"] = "Indo-European"
  1538. Locale["sd"]["iso"] = "snd"
  1539. Locale["sd"]["glotto"] = "sind1272"
  1540. Locale["sd"]["script"] = "Arab"
  1541. Locale["sd"]["rtl"] = "true"
  1542. Locale["si"]["name"] = "Sinhala"
  1543. Locale["si"]["endonym"] = "සිංහල"
  1544. Locale["si"]["translations-of"] = "%s හි පරිවර්තන"
  1545. Locale["si"]["definitions-of"] = "%s හි නිර්වචන"
  1546. Locale["si"]["synonyms"] = "සමානාර්ථ පද"
  1547. Locale["si"]["examples"] = "උදාහරණ"
  1548. Locale["si"]["see-also"] = "මෙයත් බලන්න"
  1549. Locale["si"]["family"] = "Indo-European"
  1550. Locale["si"]["iso"] = "sin"
  1551. Locale["si"]["glotto"] = "sinh1246"
  1552. Locale["si"]["script"] = "Sinh"
  1553. Locale["sk"]["name"] = "Slovak"
  1554. Locale["sk"]["endonym"] = "Slovenčina"
  1555. Locale["sk"]["translations-of"] = "Preklady výrazu: %s"
  1556. Locale["sk"]["definitions-of"] = "Definície výrazu %s"
  1557. Locale["sk"]["synonyms"] = "Synonymá"
  1558. Locale["sk"]["examples"] = "Príklady"
  1559. Locale["sk"]["see-also"] = "Pozrite tiež"
  1560. Locale["sk"]["family"] = "Indo-European"
  1561. Locale["sk"]["iso"] = "slk"
  1562. Locale["sk"]["glotto"] = "slov1269"
  1563. Locale["sk"]["script"] = "Latn"
  1564. Locale["sl"]["name"] = "Slovenian"
  1565. Locale["sl"]["endonym"] = "Slovenščina"
  1566. Locale["sl"]["translations-of"] = "Prevodi za %s"
  1567. Locale["sl"]["definitions-of"] = "Razlage za %s"
  1568. Locale["sl"]["synonyms"] = "Sopomenke"
  1569. Locale["sl"]["examples"] = "Primeri"
  1570. Locale["sl"]["see-also"] = "Glejte tudi"
  1571. Locale["sl"]["family"] = "Indo-European"
  1572. Locale["sl"]["iso"] = "slv"
  1573. Locale["sl"]["glotto"] = "slov1268"
  1574. Locale["sl"]["script"] = "Latn"
  1575. Locale["so"]["name"] = "Somali"
  1576. Locale["so"]["endonym"] = "Soomaali"
  1577. Locale["so"]["translations-of"] = "Turjumaada %s"
  1578. Locale["so"]["definitions-of"] = "Qeexitaannada %s"
  1579. Locale["so"]["synonyms"] = "La micne ah"
  1580. Locale["so"]["examples"] = "Tusaalooyin"
  1581. Locale["so"]["see-also"] = "Sidoo kale eeg"
  1582. Locale["so"]["family"] = "Afro-Asiatic"
  1583. Locale["so"]["iso"] = "som"
  1584. Locale["so"]["glotto"] = "soma1255"
  1585. Locale["so"]["script"] = "Latn"
  1586. Locale["es"]["name"] = "Spanish"
  1587. Locale["es"]["endonym"] = "Español"
  1588. Locale["es"]["translations-of"] = "Traducciones de %s"
  1589. Locale["es"]["definitions-of"] = "Definiciones de %s"
  1590. Locale["es"]["synonyms"] = "Sinónimos"
  1591. Locale["es"]["examples"] = "Ejemplos"
  1592. Locale["es"]["see-also"] = "Ver también"
  1593. Locale["es"]["family"] = "Indo-European"
  1594. Locale["es"]["iso"] = "spa"
  1595. Locale["es"]["glotto"] = "stan1288"
  1596. Locale["es"]["script"] = "Latn"
  1597. Locale["es"]["dictionary"] = "true"
  1598. Locale["su"]["name"] = "Sundanese"
  1599. Locale["su"]["endonym"] = "Basa Sunda"
  1600. Locale["su"]["translations-of"] = "Tarjamahan tina %s"
  1601. Locale["su"]["definitions-of"] = "Panjelasan tina %s"
  1602. Locale["su"]["synonyms"] = "Sinonim"
  1603. Locale["su"]["examples"] = "Conto"
  1604. Locale["su"]["see-also"] = "Tingali ogé"
  1605. Locale["su"]["family"] = "Austronesian"
  1606. Locale["su"]["iso"] = "sun"
  1607. Locale["su"]["glotto"] = "sund1252"
  1608. Locale["su"]["script"] = "Latn"
  1609. Locale["sw"]["name"] = "Swahili"
  1610. Locale["sw"]["endonym"] = "Kiswahili"
  1611. Locale["sw"]["translations-of"] = "Tafsiri ya %s"
  1612. Locale["sw"]["definitions-of"] = "Ufafanuzi wa %s"
  1613. Locale["sw"]["synonyms"] = "Visawe"
  1614. Locale["sw"]["examples"] = "Mifano"
  1615. Locale["sw"]["see-also"] = "Angalia pia"
  1616. Locale["sw"]["family"] = "Atlantic-Congo"
  1617. Locale["sw"]["iso"] = "swa"
  1618. Locale["sw"]["glotto"] = "swah1253"
  1619. Locale["sw"]["script"] = "Latn"
  1620. Locale["sv"]["name"] = "Swedish"
  1621. Locale["sv"]["endonym"] = "Svenska"
  1622. Locale["sv"]["translations-of"] = "Översättningar av %s"
  1623. Locale["sv"]["definitions-of"] = "Definitioner av %s"
  1624. Locale["sv"]["synonyms"] = "Synonymer"
  1625. Locale["sv"]["examples"] = "Exempel"
  1626. Locale["sv"]["see-also"] = "Se även"
  1627. Locale["sv"]["family"] = "Indo-European"
  1628. Locale["sv"]["iso"] = "swe"
  1629. Locale["sv"]["glotto"] = "swed1254"
  1630. Locale["sv"]["script"] = "Latn"
  1631. Locale["tg"]["name"] = "Tajik"
  1632. Locale["tg"]["endonym"] = "Тоҷикӣ"
  1633. Locale["tg"]["translations-of"] = "Тарҷумаҳои %s"
  1634. Locale["tg"]["definitions-of"] = "Таърифҳои %s"
  1635. Locale["tg"]["synonyms"] = "Муродифҳо"
  1636. Locale["tg"]["examples"] = "Намунаҳо:"
  1637. Locale["tg"]["see-also"] = "Ҳамчунин Бинед"
  1638. Locale["tg"]["family"] = "Indo-European"
  1639. Locale["tg"]["iso"] = "tgk"
  1640. Locale["tg"]["glotto"] = "taji1245"
  1641. Locale["tg"]["script"] = "Cyrl"
  1642. Locale["ta"]["name"] = "Tamil"
  1643. Locale["ta"]["endonym"] = "தமிழ்"
  1644. Locale["ta"]["translations-of"] = "%s இன் மொழிபெயர்ப்புகள்"
  1645. Locale["ta"]["definitions-of"] = "%s இன் வரையறைகள்"
  1646. Locale["ta"]["synonyms"] = "இணைச்சொற்கள்"
  1647. Locale["ta"]["examples"] = "எடுத்துக்காட்டுகள்"
  1648. Locale["ta"]["see-also"] = "இதையும் காண்க"
  1649. Locale["ta"]["family"] = "Dravidian"
  1650. Locale["ta"]["iso"] = "tam"
  1651. Locale["ta"]["glotto"] = "tami1289"
  1652. Locale["ta"]["script"] = "Taml"
  1653. Locale["te"]["name"] = "Telugu"
  1654. Locale["te"]["endonym"] = "తెలుగు"
  1655. Locale["te"]["translations-of"] = "%s యొక్క అనువాదాలు"
  1656. Locale["te"]["definitions-of"] = "%s యొక్క నిర్వచనాలు"
  1657. Locale["te"]["synonyms"] = "పర్యాయపదాలు"
  1658. Locale["te"]["examples"] = "ఉదాహరణలు"
  1659. Locale["te"]["see-also"] = "వీటిని కూడా చూడండి"
  1660. Locale["te"]["family"] = "Dravidian"
  1661. Locale["te"]["iso"] = "tel"
  1662. Locale["te"]["glotto"] = "telu1262"
  1663. Locale["te"]["script"] = "Telu"
  1664. Locale["th"]["name"] = "Thai"
  1665. Locale["th"]["endonym"] = "ไทย"
  1666. Locale["th"]["translations-of"] = "คำแปลของ %s"
  1667. Locale["th"]["definitions-of"] = "คำจำกัดความของ %s"
  1668. Locale["th"]["synonyms"] = "คำพ้องความหมาย"
  1669. Locale["th"]["examples"] = "ตัวอย่าง"
  1670. Locale["th"]["see-also"] = "ดูเพิ่มเติม"
  1671. Locale["th"]["family"] = "Tai-Kadai"
  1672. Locale["th"]["iso"] = "tha"
  1673. Locale["th"]["glotto"] = "thai1261"
  1674. Locale["th"]["script"] = "Thai"
  1675. Locale["tr"]["name"] = "Turkish"
  1676. Locale["tr"]["endonym"] = "Türkçe"
  1677. Locale["tr"]["translations-of"] = "%s çevirileri"
  1678. Locale["tr"]["definitions-of"] = "%s için tanımlar"
  1679. Locale["tr"]["synonyms"] = "Eş anlamlılar"
  1680. Locale["tr"]["examples"] = "Örnekler"
  1681. Locale["tr"]["see-also"] = "Ayrıca bkz."
  1682. Locale["tr"]["family"] = "Turkic"
  1683. Locale["tr"]["iso"] = "tur"
  1684. Locale["tr"]["glotto"] = "nucl1301"
  1685. Locale["tr"]["script"] = "Latn"
  1686. Locale["uk"]["name"] = "Ukrainian"
  1687. Locale["uk"]["endonym"] = "Українська"
  1688. Locale["uk"]["translations-of"] = "Переклади слова або виразу \"%s\""
  1689. Locale["uk"]["definitions-of"] = "\"%s\" – визначення"
  1690. Locale["uk"]["synonyms"] = "Синоніми"
  1691. Locale["uk"]["examples"] = "Приклади"
  1692. Locale["uk"]["see-also"] = "Дивіться також"
  1693. Locale["uk"]["family"] = "Indo-European"
  1694. Locale["uk"]["iso"] = "ukr"
  1695. Locale["uk"]["glotto"] = "ukra1253"
  1696. Locale["uk"]["script"] = "Cyrl"
  1697. Locale["ur"]["name"] = "Urdu"
  1698. Locale["ur"]["endonym"] = "اُردُو"
  1699. Locale["ur"]["translations-of"] = "کے ترجمے %s"
  1700. Locale["ur"]["definitions-of"] = "کی تعریفات %s"
  1701. Locale["ur"]["synonyms"] = "مترادفات"
  1702. Locale["ur"]["examples"] = "مثالیں"
  1703. Locale["ur"]["see-also"] = "نیز دیکھیں"
  1704. Locale["ur"]["family"] = "Indo-European"
  1705. Locale["ur"]["iso"] = "urd"
  1706. Locale["ur"]["glotto"] = "urdu1245"
  1707. Locale["ur"]["script"] = "Arab"
  1708. Locale["ur"]["rtl"] = "true"
  1709. Locale["uz"]["name"] = "Uzbek"
  1710. Locale["uz"]["endonym"] = "Oʻzbek tili"
  1711. Locale["uz"]["translations-of"] = "%s: tarjima variantlari"
  1712. Locale["uz"]["definitions-of"] = "%s – ta’riflar"
  1713. Locale["uz"]["synonyms"] = "Sinonimlar"
  1714. Locale["uz"]["examples"] = "Namunalar"
  1715. Locale["uz"]["see-also"] = "O‘xshash so‘zlar"
  1716. Locale["uz"]["family"] = "Turkic"
  1717. Locale["uz"]["iso"] = "uzb"
  1718. Locale["uz"]["glotto"] = "uzbe1247"
  1719. Locale["uz"]["script"] = "Latn"
  1720. Locale["vi"]["name"] = "Vietnamese"
  1721. Locale["vi"]["endonym"] = "Tiếng Việt"
  1722. Locale["vi"]["translations-of"] = "Bản dịch của %s"
  1723. Locale["vi"]["definitions-of"] = "Nghĩa của %s"
  1724. Locale["vi"]["synonyms"] = "Từ đồng nghĩa"
  1725. Locale["vi"]["examples"] = "Ví dụ"
  1726. Locale["vi"]["see-also"] = "Xem thêm"
  1727. Locale["vi"]["family"] = "Austroasiatic"
  1728. Locale["vi"]["iso"] = "vie"
  1729. Locale["vi"]["glotto"] = "viet1252"
  1730. Locale["vi"]["script"] = "Latn"
  1731. Locale["cy"]["name"] = "Welsh"
  1732. Locale["cy"]["endonym"] = "Cymraeg"
  1733. Locale["cy"]["translations-of"] = "Cyfieithiadau %s"
  1734. Locale["cy"]["definitions-of"] = "Diffiniadau %s"
  1735. Locale["cy"]["synonyms"] = "Cyfystyron"
  1736. Locale["cy"]["examples"] = "Enghreifftiau"
  1737. Locale["cy"]["see-also"] = "Gweler hefyd"
  1738. Locale["cy"]["family"] = "Indo-European"
  1739. Locale["cy"]["iso"] = "cym"
  1740. Locale["cy"]["glotto"] = "wels1247"
  1741. Locale["cy"]["script"] = "Latn"
  1742. Locale["fy"]["name"] = "Frisian"
  1743. Locale["fy"]["endonym"] = "Frysk"
  1744. Locale["fy"]["translations-of"] = "Oersettings fan %s"
  1745. Locale["fy"]["definitions-of"] = "Definysjes fan %s"
  1746. Locale["fy"]["synonyms"] = "Synonimen"
  1747. Locale["fy"]["examples"] = "Foarbylden"
  1748. Locale["fy"]["see-also"] = "Sjoch ek"
  1749. Locale["fy"]["family"] = "Indo-European"
  1750. Locale["fy"]["iso"] = "fry"
  1751. Locale["fy"]["glotto"] = "west2354"
  1752. Locale["fy"]["script"] = "Latn"
  1753. Locale["xh"]["name"] = "Xhosa"
  1754. Locale["xh"]["endonym"] = "isiXhosa"
  1755. Locale["xh"]["translations-of"] = "Iinguqulelo zika-%s"
  1756. Locale["xh"]["definitions-of"] = "Iingcaciso zika-%s"
  1757. Locale["xh"]["synonyms"] = "Izithethantonye"
  1758. Locale["xh"]["examples"] = "Imizekelo"
  1759. Locale["xh"]["see-also"] = "Kwakhona bona"
  1760. Locale["xh"]["family"] = "Atlantic-Congo"
  1761. Locale["xh"]["iso"] = "xho"
  1762. Locale["xh"]["glotto"] = "xhos1239"
  1763. Locale["xh"]["script"] = "Latn"
  1764. Locale["yi"]["name"] = "Yiddish"
  1765. Locale["yi"]["endonym"] = "ייִדיש"
  1766. Locale["yi"]["translations-of"] = "איבערזעצונגען פון %s"
  1767. Locale["yi"]["definitions-of"] = "דפיניציונען %s"
  1768. Locale["yi"]["synonyms"] = "סינאָנימען"
  1769. Locale["yi"]["examples"] = "ביישפילע"
  1770. Locale["yi"]["see-also"] = "זייען אויך"
  1771. Locale["yi"]["family"] = "Indo-European"
  1772. Locale["yi"]["iso"] = "yid"
  1773. Locale["yi"]["glotto"] = "yidd1255"
  1774. Locale["yi"]["script"] = "Hebr"
  1775. Locale["yi"]["rtl"] = "true"
  1776. Locale["yo"]["name"] = "Yoruba"
  1777. Locale["yo"]["endonym"] = "Yorùbá"
  1778. Locale["yo"]["translations-of"] = "Awọn itumọ ti %s"
  1779. Locale["yo"]["definitions-of"] = "Awọn itumọ ti %s"
  1780. Locale["yo"]["synonyms"] = "Awọn ọrọ onitumọ"
  1781. Locale["yo"]["examples"] = "Awọn apẹrẹ"
  1782. Locale["yo"]["see-also"] = "Tun wo"
  1783. Locale["yo"]["family"] = "Atlantic-Congo"
  1784. Locale["yo"]["iso"] = "yor"
  1785. Locale["yo"]["glotto"] = "yoru1245"
  1786. Locale["yo"]["script"] = "Latn"
  1787. Locale["zu"]["name"] = "Zulu"
  1788. Locale["zu"]["endonym"] = "isiZulu"
  1789. Locale["zu"]["translations-of"] = "Ukuhumusha i-%s"
  1790. Locale["zu"]["definitions-of"] = "Izincazelo ze-%s"
  1791. Locale["zu"]["synonyms"] = "Amagama afanayo"
  1792. Locale["zu"]["examples"] = "Izibonelo"
  1793. Locale["zu"]["see-also"] = "Bheka futhi"
  1794. Locale["zu"]["family"] = "Atlantic-Congo"
  1795. Locale["zu"]["iso"] = "zul"
  1796. Locale["zu"]["glotto"] = "zulu1248"
  1797. Locale["zu"]["script"] = "Latn"
  1798. Locale["yue"]["support"] = "bing-only"
  1799. Locale["yue"]["name"] = "Cantonese"
  1800. Locale["yue"]["endonym"] = "粵語"
  1801. Locale["yue"]["family"] = "Sino-Tibetan"
  1802. Locale["yue"]["iso"] = "yue"
  1803. Locale["yue"]["glotto"] = "cant1236"
  1804. Locale["yue"]["script"] = "Hant"
  1805. Locale["fj"]["support"] = "bing-only"
  1806. Locale["fj"]["name"] = "Fijian"
  1807. Locale["fj"]["endonym"] = "Vosa Vakaviti"
  1808. Locale["fj"]["family"] = "Austronesian"
  1809. Locale["fj"]["iso"] = "fij"
  1810. Locale["fj"]["glotto"] = "fiji1243"
  1811. Locale["fj"]["script"] = "Latn"
  1812. Locale["mww"]["support"] = "bing-only"
  1813. Locale["mww"]["name"] = "Hmong Daw"
  1814. Locale["mww"]["endonym"] = "Hmoob Daw"
  1815. Locale["mww"]["family"] = "Hmong-Mien"
  1816. Locale["mww"]["iso"] = "mww"
  1817. Locale["mww"]["glotto"] = "hmon1333"
  1818. Locale["mww"]["script"] = "Latn"
  1819. Locale["otq"]["support"] = "bing-only"
  1820. Locale["otq"]["name"] = "Querétaro Otomi"
  1821. Locale["otq"]["endonym"] = "Hñąñho"
  1822. Locale["otq"]["family"] = "Oto-Manguean"
  1823. Locale["otq"]["iso"] = "otq"
  1824. Locale["otq"]["glotto"] = "quer1236"
  1825. Locale["otq"]["script"] = "Latn"
  1826. Locale["ty"]["support"] = "bing-only"
  1827. Locale["ty"]["name"] = "Tahitian"
  1828. Locale["ty"]["endonym"] = "Reo Tahiti"
  1829. Locale["ty"]["family"] = "Austronesian"
  1830. Locale["ty"]["iso"] = "tah"
  1831. Locale["ty"]["glotto"] = "tahi1242"
  1832. Locale["ty"]["script"] = "Latn"
  1833. Locale["to"]["support"] = "bing-only"
  1834. Locale["to"]["name"] = "Tongan"
  1835. Locale["to"]["endonym"] = "Lea faka-Tonga"
  1836. Locale["to"]["family"] = "Austronesian"
  1837. Locale["to"]["iso"] = "ton"
  1838. Locale["to"]["glotto"] = "tong1325"
  1839. Locale["to"]["script"] = "Latn"
  1840. Locale["yua"]["support"] = "bing-only"
  1841. Locale["yua"]["name"] = "Yucatec Maya"
  1842. Locale["yua"]["endonym"] = "Màaya T'àan"
  1843. Locale["yua"]["family"] = "Mayan"
  1844. Locale["yua"]["iso"] = "yua"
  1845. Locale["yua"]["glotto"] = "yuca1254"
  1846. Locale["yua"]["script"] = "Latn"
  1847. Locale["tlh"]["support"] = "bing-only"
  1848. Locale["tlh"]["name"] = "Klingon"
  1849. Locale["tlh"]["endonym"] = "tlhIngan Hol"
  1850. Locale["tlh"]["family"] = "Artificial Language"
  1851. Locale["tlh"]["iso"] = "tlh"
  1852. Locale["tlh"]["script"] = "Latn"
  1853. Locale["tlh-Qaak"]["support"] = "bing-only"
  1854. Locale["tlh-Qaak"]["name"] = "Klingon (pIqaD)"
  1855. Locale["tlh-Qaak"]["endonym"] = " "
  1856. Locale["tlh-Qaak"]["family"] = "Artificial Language"
  1857. Locale["tlh-Qaak"]["iso"] = "tlh"
  1858. Locale["tlh-Qaak"]["script"] = "Piqd"
  1859. Locale["as"]["support"] = "unstable"
  1860. Locale["as"]["name"] = "Assamese"
  1861. Locale["as"]["endonym"] = "অসমীয়া"
  1862. Locale["as"]["family"] = "Indo-European"
  1863. Locale["as"]["iso"] = "asm"
  1864. Locale["as"]["glotto"] = "assa1263"
  1865. Locale["as"]["script"] = "Beng"
  1866. Locale["ba"]["support"] = "yandex-only"
  1867. Locale["ba"]["name"] = "Bashkir"
  1868. Locale["ba"]["endonym"] = "башҡорт теле"
  1869. Locale["ba"]["family"] = "Turkic"
  1870. Locale["ba"]["iso"] = "bak"
  1871. Locale["ba"]["glotto"] = "bash1264"
  1872. Locale["ba"]["script"] = "Cyrl"
  1873. Locale["br"]["support"] = "unstable"
  1874. Locale["br"]["name"] = "Breton"
  1875. Locale["br"]["endonym"] = "Brezhoneg"
  1876. Locale["br"]["family"] = "Indo-European"
  1877. Locale["br"]["iso"] = "bre"
  1878. Locale["br"]["glotto"] = "bret1244"
  1879. Locale["br"]["script"] = "Latn"
  1880. Locale["dz"]["support"] = "unstable"
  1881. Locale["dz"]["name"] = "Dzongkha"
  1882. Locale["dz"]["endonym"] = "རྫོང་ཁ"
  1883. Locale["dz"]["family"] = "Sino-Tibetan"
  1884. Locale["dz"]["iso"] = "dzo"
  1885. Locale["dz"]["glotto"] = "nucl1307"
  1886. Locale["dz"]["script"] = "Tibt"
  1887. Locale["mhr"]["support"] = "yandex-only"
  1888. Locale["mhr"]["name"] = "Eastern Mari"
  1889. Locale["mhr"]["endonym"] = "Олык марий"
  1890. Locale["mhr"]["family"] = "Uralic"
  1891. Locale["mhr"]["iso"] = "mhr"
  1892. Locale["mhr"]["glotto"] = "east2328"
  1893. Locale["mhr"]["script"] = "Cyrl"
  1894. Locale["fo"]["support"] = "unstable"
  1895. Locale["fo"]["name"] = "Faroese"
  1896. Locale["fo"]["endonym"] = "Føroyskt"
  1897. Locale["fo"]["family"] = "Indo-European"
  1898. Locale["fo"]["iso"] = "fao"
  1899. Locale["fo"]["glotto"] = "faro1244"
  1900. Locale["fo"]["script"] = "Latn"
  1901. Locale["gn"]["support"] = "unstable"
  1902. Locale["gn"]["name"] = "Guarani"
  1903. Locale["gn"]["endonym"] = "Avañe'ẽ"
  1904. Locale["gn"]["family"] = "Tupian"
  1905. Locale["gn"]["iso"] = "grn"
  1906. Locale["gn"]["glotto"] = "para1311"
  1907. Locale["gn"]["script"] = "Latn"
  1908. Locale["mrj"]["support"] = "yandex-only"
  1909. Locale["mrj"]["name"] = "Hill Mari"
  1910. Locale["mrj"]["endonym"] = "Кырык мары"
  1911. Locale["mrj"]["family"] = "Uralic"
  1912. Locale["mrj"]["iso"] = "mrj"
  1913. Locale["mrj"]["glotto"] = "west2392"
  1914. Locale["mrj"]["script"] = "Cyrl"
  1915. Locale["ie"]["support"] = "unstable"
  1916. Locale["ie"]["name"] = "Interlingue"
  1917. Locale["ie"]["endonym"] = "Interlingue"
  1918. Locale["ie"]["family"] = "Artificial Language"
  1919. Locale["ie"]["iso"] = "ile"
  1920. Locale["ie"]["glotto"] = "occi1241"
  1921. Locale["ie"]["script"] = "Latn"
  1922. Locale["rw"]["support"] = "unstable"
  1923. Locale["rw"]["name"] = "Kinyarwanda"
  1924. Locale["rw"]["endonym"] = "Ikinyarwanda"
  1925. Locale["rw"]["family"] = "Atlantic-Congo"
  1926. Locale["rw"]["iso"] = "kin"
  1927. Locale["rw"]["glotto"] = "kiny1244"
  1928. Locale["rw"]["script"] = "Latn"
  1929. Locale["oc"]["support"] = "unstable"
  1930. Locale["oc"]["name"] = "Occitan"
  1931. Locale["oc"]["endonym"] = "Occitan"
  1932. Locale["oc"]["family"] = "Indo-European"
  1933. Locale["oc"]["iso"] = "oci"
  1934. Locale["oc"]["glotto"] = "occi1239"
  1935. Locale["oc"]["script"] = "Latn"
  1936. Locale["om"]["support"] = "unstable"
  1937. Locale["om"]["name"] = "Oromo"
  1938. Locale["om"]["endonym"] = "Afaan Oromoo"
  1939. Locale["om"]["family"] = "Afro-Asiatic"
  1940. Locale["om"]["iso"] = "orm"
  1941. Locale["om"]["glotto"] = "nucl1736"
  1942. Locale["om"]["script"] = "Latn"
  1943. Locale["or"]["support"] = "unstable"
  1944. Locale["or"]["name"] = "Oriya"
  1945. Locale["or"]["endonym"] = "ଓଡ଼ିଆ"
  1946. Locale["or"]["family"] = "Indo-European"
  1947. Locale["or"]["iso"] = "ori"
  1948. Locale["or"]["glotto"] = "macr1269"
  1949. Locale["or"]["script"] = "Orya"
  1950. Locale["pap"]["support"] = "yandex-only"
  1951. Locale["pap"]["name"] = "Papiamento"
  1952. Locale["pap"]["endonym"] = "Papiamentu"
  1953. Locale["pap"]["family"] = "Indo-European"
  1954. Locale["pap"]["iso"] = "pap"
  1955. Locale["pap"]["glotto"] = "papi1253"
  1956. Locale["pap"]["script"] = "Latn"
  1957. Locale["rm"]["support"] = "unstable"
  1958. Locale["rm"]["name"] = "Romansh"
  1959. Locale["rm"]["endonym"] = "Rumantsch"
  1960. Locale["rm"]["family"] = "Indo-European"
  1961. Locale["rm"]["iso"] = "roh"
  1962. Locale["rm"]["glotto"] = "roma1326"
  1963. Locale["rm"]["script"] = "Latn"
  1964. Locale["ti"]["support"] = "unstable"
  1965. Locale["ti"]["name"] = "Tigrinya"
  1966. Locale["ti"]["endonym"] = "ትግርኛ"
  1967. Locale["ti"]["family"] = "Afro-Asiatic"
  1968. Locale["ti"]["iso"] = "tir"
  1969. Locale["ti"]["glotto"] = "tigr1271"
  1970. Locale["ti"]["script"] = "Ethi"
  1971. Locale["bo"]["support"] = "unstable"
  1972. Locale["bo"]["name"] = "Tibetan"
  1973. Locale["bo"]["endonym"] = "བོད་ཡིག"
  1974. Locale["bo"]["family"] = "Sino-Tibetan"
  1975. Locale["bo"]["iso"] = "bod"
  1976. Locale["bo"]["glotto"] = "tibe1272"
  1977. Locale["bo"]["script"] = "Tibt"
  1978. Locale["tk"]["support"] = "unstable"
  1979. Locale["tk"]["name"] = "Turkmen"
  1980. Locale["tk"]["endonym"] = "Türkmen"
  1981. Locale["tk"]["family"] = "Turkic"
  1982. Locale["tk"]["iso"] = "tuk"
  1983. Locale["tk"]["glotto"] = "turk1304"
  1984. Locale["tk"]["script"] = "Latn"
  1985. Locale["tt"]["support"] = "yandex-only"
  1986. Locale["tt"]["name"] = "Tatar"
  1987. Locale["tt"]["endonym"] = "татарча"
  1988. Locale["tt"]["family"] = "Turkic"
  1989. Locale["tt"]["iso"] = "tat"
  1990. Locale["tt"]["glotto"] = "tata1255"
  1991. Locale["tt"]["script"] = "Cyrl"
  1992. Locale["udm"]["support"] = "yandex-only"
  1993. Locale["udm"]["name"] = "Udmurt"
  1994. Locale["udm"]["endonym"] = "удмурт"
  1995. Locale["udm"]["family"] = "Uralic"
  1996. Locale["udm"]["iso"] = "udm"
  1997. Locale["udm"]["glotto"] = "udmu1245"
  1998. Locale["udm"]["script"] = "Cyrl"
  1999. Locale["ug"]["support"] = "unstable"
  2000. Locale["ug"]["name"] = "Uyghur"
  2001. Locale["ug"]["endonym"] = "ئۇيغۇر تىلى"
  2002. Locale["ug"]["family"] = "Turkic"
  2003. Locale["ug"]["iso"] = "uig"
  2004. Locale["ug"]["glotto"] = "uigh1240"
  2005. Locale["ug"]["script"] = "Arab"
  2006. Locale["ug"]["rtl"] = "true"
  2007. Locale["vo"]["support"] = "unstable"
  2008. Locale["vo"]["name"] = "Volapük"
  2009. Locale["vo"]["endonym"] = "Volapük"
  2010. Locale["vo"]["family"] = "Artificial Language"
  2011. Locale["vo"]["iso"] = "vol"
  2012. Locale["vo"]["script"] = "Latn"
  2013. Locale["wo"]["support"] = "unstable"
  2014. Locale["wo"]["name"] = "Wolof"
  2015. Locale["wo"]["endonym"] = "Wollof"
  2016. Locale["wo"]["family"] = "Atlantic-Congo"
  2017. Locale["wo"]["iso"] = "wol"
  2018. Locale["wo"]["glotto"] = "wolo1247"
  2019. Locale["wo"]["script"] = "Latn"
  2020. Locale["chr"]["support"] = "unstable"
  2021. Locale["chr"]["name"] = "Cherokee"
  2022. Locale["chr"]["endonym"] = "ᏣᎳᎩ"
  2023. Locale["chr"]["family"] = "Iroquoian"
  2024. Locale["chr"]["iso"] = "chr"
  2025. Locale["chr"]["glotto"] = "cher1273"
  2026. Locale["chr"]["script"] = "Cher"
  2027. Locale["emj"]["support"] = "yandex-only"
  2028. Locale["emj"]["name"] = "Emoji"
  2029. Locale["emj"]["endonym"] = "Emoji"
  2030. }
  2031. function initLocaleAlias( i) {
  2032. for (i in Locale) {
  2033. LocaleAlias[Locale[i]["iso"]] = i
  2034. LocaleAlias[tolower(Locale[i]["name"])] = i
  2035. LocaleAlias[tolower(Locale[i]["endonym"])] = i
  2036. }
  2037. LocaleAlias["in"] = "id"
  2038. LocaleAlias["iw"] = "he"
  2039. LocaleAlias["ji"] = "yi"
  2040. LocaleAlias["jw"] = "jv"
  2041. LocaleAlias["mo"] = "ro"
  2042. LocaleAlias["nb"] = "no"
  2043. LocaleAlias["nn"] = "no"
  2044. LocaleAlias["sh"] = "sr-Cyrl"
  2045. LocaleAlias["sr"] = "sr-Cyrl"
  2046. LocaleAlias["srp"] = "sr-Cyrl"
  2047. LocaleAlias["serbian"] = "sr-Cyrl"
  2048. LocaleAlias["zh"] = "zh-CN"
  2049. LocaleAlias["zh-CHS"] = "zh-CN"
  2050. LocaleAlias["zh-CHT"] = "zh-TW"
  2051. LocaleAlias["zh-Hans"] = "zh-CN"
  2052. LocaleAlias["zh-Hant"] = "zh-TW"
  2053. LocaleAlias["zho"] = "zh-CN"
  2054. LocaleAlias["chinese"] = "zh-CN"
  2055. LocaleAlias["tlh-Latn"] = "tlh"
  2056. LocaleAlias["tlh-Piqd"] = "tlh-Qaak"
  2057. }
  2058. function initLocaleDisplay( i) {
  2059. for (i in Locale) {
  2060. Locale[i]["display"] = show(Locale[i]["endonym"], i)
  2061. }
  2062. }
  2063. function getCode(code, group) {
  2064. if (code == "auto" || code in Locale)
  2065. return code
  2066. else if (code in LocaleAlias)
  2067. return LocaleAlias[code]
  2068. else if (tolower(code) in LocaleAlias)
  2069. return LocaleAlias[tolower(code)]
  2070. match(code, /^([[:alpha:]][[:alpha:]][[:alpha:]]?)-(.*)$/, group)
  2071. if (group[1])
  2072. return group[1]
  2073. return
  2074. }
  2075. function getName(code) {
  2076. return Locale[getCode(code)]["name"]
  2077. }
  2078. function getEndonym(code) {
  2079. return Locale[getCode(code)]["endonym"]
  2080. }
  2081. function getDisplay(code) {
  2082. return Locale[getCode(code)]["display"]
  2083. }
  2084. function showTranslationsOf(code, text, fmt) {
  2085. fmt = Locale[getCode(code)]["translations-of"]
  2086. if (!fmt) fmt = Locale["en"]["translations-of"]
  2087. return sprintf(fmt, text)
  2088. }
  2089. function showDefinitionsOf(code, text, fmt) {
  2090. fmt = Locale[getCode(code)]["definitions-of"]
  2091. if (!fmt) fmt = Locale["en"]["definitions-of"]
  2092. return sprintf(fmt, text)
  2093. }
  2094. function showSynonyms(code, tmp) {
  2095. tmp = Locale[getCode(code)]["synonyms"]
  2096. if (!tmp) tmp = Locale["en"]["synonyms"]
  2097. return tmp
  2098. }
  2099. function showExamples(code, tmp) {
  2100. tmp = Locale[getCode(code)]["examples"]
  2101. if (!tmp) tmp = Locale["en"]["examples"]
  2102. return tmp
  2103. }
  2104. function showSeeAlso(code, tmp) {
  2105. tmp = Locale[getCode(code)]["see-also"]
  2106. if (!tmp) tmp = Locale["en"]["see-also"]
  2107. return tmp
  2108. }
  2109. function getFamily(code) {
  2110. return Locale[getCode(code)]["family"]
  2111. }
  2112. function getISO(code) {
  2113. return Locale[getCode(code)]["iso"]
  2114. }
  2115. function getGlotto(code) {
  2116. return Locale[getCode(code)]["glotto"]
  2117. }
  2118. function getScript(code) {
  2119. return Locale[getCode(code)]["script"]
  2120. }
  2121. function isRTL(code) {
  2122. return Locale[getCode(code)]["rtl"] ? 1 : 0
  2123. }
  2124. function hasDictionary(code) {
  2125. return Locale[getCode(code)]["dictionary"] ? 1 : 0
  2126. }
  2127. function compName(i1, v1, i2, v2) {
  2128. if (getName(i1) < getName(i2))
  2129. return -1
  2130. else
  2131. return (getName(i1) != getName(i2))
  2132. }
  2133. function scriptName(code) {
  2134. switch (code) {
  2135. case "Arab": return "Arabic"
  2136. case "Armn": return "Armenian"
  2137. case "Beng": return "Bengali"
  2138. case "Cher": return "Cherokee"
  2139. case "Cyrl": return "Cyrillic"
  2140. case "Deva": return "Devanagari"
  2141. case "Ethi": return "Ethiopic (Geʻez)"
  2142. case "Geor": return "Georgian (Mkhedruli)"
  2143. case "Grek": return "Greek"
  2144. case "Gujr": return "Gujarati"
  2145. case "Guru": return "Gurmukhi"
  2146. case "Hani": return "Han"
  2147. case "Hans": return "Han (Simplified)"
  2148. case "Hant": return "Han (Traditional)"
  2149. case "Hebr": return "Hebrew"
  2150. case "Jpan": return "Japanese (Han + Hiragana + Katakana)"
  2151. case "Khmr": return "Khmer"
  2152. case "Knda": return "Kannada"
  2153. case "Kore": return "Korean (Hangul + Han)"
  2154. case "Laoo": return "Lao"
  2155. case "Latn": return "Latin"
  2156. case "Mlym": return "Malayalam"
  2157. case "Mymr": return "Myanmar"
  2158. case "Orya": return "Oriya"
  2159. case "Piqd": return "Klingon (pIqaD)"
  2160. case "Sinh": return "Sinhala"
  2161. case "Taml": return "Tamil"
  2162. case "Telu": return "Telugu"
  2163. case "Thai": return "Thai"
  2164. case "Tibt": return "Tibetan"
  2165. default: return "Unknown"
  2166. }
  2167. }
  2168. function getDetails(code, group, iso, language, script) {
  2169. if (code == "auto" || !getCode(code)) {
  2170. e("[ERROR] Language not found: " code "\n"\
  2171. " Run '-reference / -R' to see a list of available languages.")
  2172. exit 1
  2173. }
  2174. script = scriptName(getScript(code))
  2175. if (isRTL(code)) script = script " (R-to-L)"
  2176. split(getISO(code), group, "-")
  2177. iso = group[1]
  2178. split(getName(code), group, " ")
  2179. language = length(group) == 1 ? group[1] "_language" :
  2180. group[2] ~ /^\(.*\)$/ ? group[1] "_language" : join(group, "_")
  2181. return ansi("bold", sprintf("%s\n", getDisplay(code)))\
  2182. sprintf("%-22s%s\n", "Name", ansi("bold", getName(code)))\
  2183. sprintf("%-22s%s\n", "Family", ansi("bold", getFamily(code)))\
  2184. sprintf("%-22s%s\n", "Writing system", ansi("bold", script))\
  2185. sprintf("%-22s%s\n", "Code", ansi("bold", getCode(code)))\
  2186. sprintf("%-22s%s\n", "ISO 639-3", ansi("bold", iso))\
  2187. sprintf("%-22s%s\n", "SIL", ansi("bold", "http://www-01.sil.org/iso639-3/documentation.asp?id=" iso))\
  2188. sprintf("%-22s%s\n", "Glottolog", getGlotto(code) ?
  2189. ansi("bold", "http://glottolog.org/resource/languoid/id/" getGlotto(code)) : "")\
  2190. sprintf("%-22s%s", "Wikipedia", ansi("bold", "http://en.wikipedia.org/wiki/" language))
  2191. }
  2192. function showPhonetics(phonetics, code) {
  2193. if (code && getCode(code) == "en")
  2194. return "/" phonetics "/"
  2195. else
  2196. return "(" phonetics ")"
  2197. }
  2198. function show(text, code, command, temp) {
  2199. if (!code || isRTL(code)) {
  2200. if (Cache[text][0])
  2201. return Cache[text][0]
  2202. else {
  2203. if ((FriBidi || (code && isRTL(code))) && BiDiNoPad) {
  2204. command = "echo " parameterize(text) PIPE BiDiNoPad
  2205. command | getline temp
  2206. close(command)
  2207. } else
  2208. temp = text
  2209. return Cache[text][0] = temp
  2210. }
  2211. } else
  2212. return text
  2213. }
  2214. function s(text, code, width, command, temp) {
  2215. if (!code || isRTL(code)) {
  2216. if (!width) width = Option["width"]
  2217. if (Cache[text][width])
  2218. return Cache[text][width]
  2219. else {
  2220. if ((FriBidi || (code && isRTL(code))) && BiDi) {
  2221. command = "echo " parameterize(text) PIPE sprintf(BiDi, width)
  2222. command | getline temp
  2223. close(command)
  2224. } else
  2225. temp = text
  2226. return Cache[text][width] = temp
  2227. }
  2228. } else
  2229. return text
  2230. }
  2231. function ins(level, text, code, width, i, temp) {
  2232. if (code && isRTL(code)) {
  2233. if (!width) width = Option["width"]
  2234. return s(text, code, width - Option["indent"] * level)
  2235. } else
  2236. return replicate(" ", Option["indent"] * level) text
  2237. }
  2238. function parseLang(lang, code, group) {
  2239. match(lang, /^([a-z][a-z][a-z]?)(_|$)/, group)
  2240. code = getCode(group[1])
  2241. if (lang ~ /^zh_(CN|SG)/) code = "zh-CN"
  2242. else if (lang ~ /^zh_(TW|HK)/) code = "zh-TW"
  2243. if (!code) code = "en"
  2244. return code
  2245. }
  2246. function initUserLang( lang, utf) {
  2247. if (lang = ENVIRON["LC_ALL"]) {
  2248. if (!UserLocale) UserLocale = lang
  2249. utf = utf || tolower(lang) ~ /utf-?8$/
  2250. }
  2251. if (lang = ENVIRON["LANG"]) {
  2252. if (!UserLocale) UserLocale = lang
  2253. utf = utf || tolower(lang) ~ /utf-?8$/
  2254. }
  2255. if (!UserLocale) {
  2256. UserLocale = "en_US.UTF-8"
  2257. utf = 1
  2258. }
  2259. if (!utf)
  2260. w("[WARNING] Your locale codeset (" UserLocale ") is not UTF-8.")
  2261. UserLang = parseLang(UserLocale)
  2262. }
  2263. function getVersion( build, gitHead) {
  2264. initAudioPlayer()
  2265. initPager()
  2266. Platform = Platform ? Platform : detectProgram("uname", "-s", 1)
  2267. if (ENVIRON["TRANS_BUILD"])
  2268. build = "-" ENVIRON["TRANS_BUILD"]
  2269. else {
  2270. gitHead = getGitHead()
  2271. build = gitHead ? "-git:" gitHead : ""
  2272. }
  2273. return ansi("bold", sprintf("%-22s%s%s\n\n", Name, Version, build))\
  2274. sprintf("%-22s%s\n", "platform", Platform)\
  2275. sprintf("%-22s%s\n", "terminal type", ENVIRON["TERM"])\
  2276. sprintf("%-22s%s\n", "bi-di emulator", BiDiTerm ? BiDiTerm :
  2277. "[N/A]")\
  2278. sprintf("%-22s%s\n", "gawk (GNU Awk)", PROCINFO["version"])\
  2279. sprintf("%s\n", FriBidi ? FriBidi :
  2280. "fribidi (GNU FriBidi) [NOT INSTALLED]")\
  2281. sprintf("%-22s%s\n", "audio player", AudioPlayer ? AudioPlayer :
  2282. "[NOT INSTALLED]")\
  2283. sprintf("%-22s%s\n", "terminal pager", Pager ? Pager :
  2284. "[NOT INSTALLED]")\
  2285. sprintf("%-22s%s\n", "web browser", Option["browser"] != NONE ?
  2286. Option["browser"] :"[NONE]")\
  2287. sprintf("%-22s%s (%s)\n", "user locale", UserLocale, getName(UserLang))\
  2288. sprintf("%-22s%s\n", "home language", Option["hl"])\
  2289. sprintf("%-22s%s\n", "source language", join(Option["sls"], "+"))\
  2290. sprintf("%-22s%s\n", "target language", join(Option["tl"], "+"))\
  2291. sprintf("%-22s%s\n", "translation engine", Option["engine"])\
  2292. sprintf("%-22s%s\n", "proxy", Option["proxy"] ? Option["proxy"] :
  2293. "[NONE]")\
  2294. sprintf("%-22s%s\n", "user-agent", Option["user-agent"] ? Option["user-agent"] :
  2295. "[NONE]")\
  2296. sprintf("%-22s%s\n", "ip version", Option["ip-version"] ? Option["ip-version"] :
  2297. "[DEFAULT]")\
  2298. sprintf("%-22s%s\n", "theme", Option["theme"])\
  2299. sprintf("%-22s%s\n", "init file", InitScript ? InitScript : "[NONE]")\
  2300. sprintf("\n%-22s%s", "Report bugs to:", "https://github.com/soimort/translate-shell/issues")
  2301. }
  2302. function getHelp() {
  2303. return "Usage: " ansi("bold", Command)\
  2304. " [" ansi("underline", "OPTIONS") "]"\
  2305. " [" ansi("underline", "SOURCES") "]"\
  2306. ":[" ansi("underline", "TARGETS") "]"\
  2307. " [" ansi("underline", "TEXT") "]..." RS\
  2308. RS "Information options:" RS\
  2309. ins(1, ansi("bold", "-V") ", " ansi("bold", "-version")) RS\
  2310. ins(2, "Print version and exit.") RS\
  2311. ins(1, ansi("bold", "-H") ", " ansi("bold", "-help")) RS\
  2312. ins(2, "Print help message and exit.") RS\
  2313. ins(1, ansi("bold", "-M") ", " ansi("bold", "-man")) RS\
  2314. ins(2, "Show man page and exit.") RS\
  2315. ins(1, ansi("bold", "-T") ", " ansi("bold", "-reference")) RS\
  2316. ins(2, "Print reference table of languages and exit.") RS\
  2317. ins(1, ansi("bold", "-R") ", " ansi("bold", "-reference-english")) RS\
  2318. ins(2, "Print reference table of languages (in English names) and exit.") RS\
  2319. ins(1, ansi("bold", "-L ") ansi("underline", "CODES")\
  2320. ", " ansi("bold", "-list ") ansi("underline", "CODES")) RS\
  2321. ins(2, "Print details of languages and exit.") RS\
  2322. ins(1, ansi("bold", "-S") ", " ansi("bold", "-list-engines")) RS\
  2323. ins(2, "List available translation engines and exit.") RS\
  2324. ins(1, ansi("bold", "-U") ", " ansi("bold", "-upgrade")) RS\
  2325. ins(2, "Check for upgrade of this program.") RS\
  2326. RS "Translator options:" RS\
  2327. ins(1, ansi("bold", "-e ") ansi("underline", "ENGINE")\
  2328. ", " ansi("bold", "-engine ") ansi("underline", "ENGINE")) RS\
  2329. ins(2, "Specify the translation engine to use.") RS\
  2330. RS "Display options:" RS\
  2331. ins(1, ansi("bold", "-verbose")) RS\
  2332. ins(2, "Verbose mode. (default)") RS\
  2333. ins(1, ansi("bold", "-b") ", " ansi("bold", "-brief")) RS\
  2334. ins(2, "Brief mode.") RS\
  2335. ins(1, ansi("bold", "-d") ", " ansi("bold", "-dictionary")) RS\
  2336. ins(2, "Dictionary mode.") RS\
  2337. ins(1, ansi("bold", "-identify")) RS\
  2338. ins(2, "Language identification.") RS\
  2339. ins(1, ansi("bold", "-show-original ") ansi("underline", "Y/n")) RS\
  2340. ins(2, "Show original text or not.") RS\
  2341. ins(1, ansi("bold", "-show-original-phonetics ") ansi("underline", "Y/n")) RS\
  2342. ins(2, "Show phonetic notation of original text or not.") RS\
  2343. ins(1, ansi("bold", "-show-translation ") ansi("underline", "Y/n")) RS\
  2344. ins(2, "Show translation or not.") RS\
  2345. ins(1, ansi("bold", "-show-translation-phonetics ") ansi("underline", "Y/n")) RS\
  2346. ins(2, "Show phonetic notation of translation or not.") RS\
  2347. ins(1, ansi("bold", "-show-prompt-message ") ansi("underline", "Y/n")) RS\
  2348. ins(2, "Show prompt message or not.") RS\
  2349. ins(1, ansi("bold", "-show-languages ") ansi("underline", "Y/n")) RS\
  2350. ins(2, "Show source and target languages or not.") RS\
  2351. ins(1, ansi("bold", "-show-original-dictionary ") ansi("underline", "y/N")) RS\
  2352. ins(2, "Show dictionary entry of original text or not.") RS\
  2353. ins(1, ansi("bold", "-show-dictionary ") ansi("underline", "Y/n")) RS\
  2354. ins(2, "Show dictionary entry of translation or not.") RS\
  2355. ins(1, ansi("bold", "-show-alternatives ") ansi("underline", "Y/n")) RS\
  2356. ins(2, "Show alternative translations or not.") RS\
  2357. ins(1, ansi("bold", "-w ") ansi("underline", "NUM")\
  2358. ", " ansi("bold", "-width ") ansi("underline", "NUM")) RS\
  2359. ins(2, "Specify the screen width for padding.") RS\
  2360. ins(1, ansi("bold", "-indent ") ansi("underline", "NUM")) RS\
  2361. ins(2, "Specify the size of indent (number of spaces).") RS\
  2362. ins(1, ansi("bold", "-theme ") ansi("underline", "FILENAME")) RS\
  2363. ins(2, "Specify the theme to use.") RS\
  2364. ins(1, ansi("bold", "-no-theme")) RS\
  2365. ins(2, "Do not use any other theme than default.") RS\
  2366. ins(1, ansi("bold", "-no-ansi")) RS\
  2367. ins(2, "Do not use ANSI escape codes.") RS\
  2368. ins(1, ansi("bold", "-no-autocorrect")) RS\
  2369. ins(2, "Do not autocorrect. (if defaulted by the translation engine)") RS\
  2370. ins(1, ansi("bold", "-no-bidi")) RS\
  2371. ins(2, "Do not convert bidirectional texts.") RS\
  2372. ins(1, ansi("bold", "-bidi")) RS\
  2373. ins(2, "Always convert bidirectional texts.") RS\
  2374. ins(1, ansi("bold", "-no-warn")) RS\
  2375. ins(2, "Do not write warning messages to stderr.") RS\
  2376. ins(1, ansi("bold", "-dump")) RS\
  2377. ins(2, "Print raw API response instead.") RS\
  2378. RS "Audio options:" RS\
  2379. ins(1, ansi("bold", "-p, -play")) RS\
  2380. ins(2, "Listen to the translation.") RS\
  2381. ins(1, ansi("bold", "-speak")) RS\
  2382. ins(2, "Listen to the original text.") RS\
  2383. ins(1, ansi("bold", "-n ") ansi("underline", "VOICE")\
  2384. ", " ansi("bold", "-narrator ") ansi("underline", "VOICE")) RS\
  2385. ins(2, "Specify the narrator, and listen to the translation.") RS\
  2386. ins(1, ansi("bold", "-player ") ansi("underline", "PROGRAM")) RS\
  2387. ins(2, "Specify the audio player to use, and listen to the translation.") RS\
  2388. ins(1, ansi("bold", "-no-play")) RS\
  2389. ins(2, "Do not listen to the translation.") RS\
  2390. ins(1, ansi("bold", "-no-translate")) RS\
  2391. ins(2, "Do not translate anything when using -speak.") RS\
  2392. ins(1, ansi("bold", "-download-audio")) RS\
  2393. ins(2, "Download the audio to the current directory.") RS\
  2394. ins(1, ansi("bold", "-download-audio-as ") ansi("underline", "FILENAME")) RS\
  2395. ins(2, "Download the audio to the specified file.") RS\
  2396. RS "Terminal paging and browsing options:" RS\
  2397. ins(1, ansi("bold", "-v") ", " ansi("bold", "-view")) RS\
  2398. ins(2, "View the translation in a terminal pager.") RS\
  2399. ins(1, ansi("bold", "-pager ") ansi("underline", "PROGRAM")) RS\
  2400. ins(2, "Specify the terminal pager to use, and view the translation.") RS\
  2401. ins(1, ansi("bold", "-no-view") ", " ansi("bold", "-no-pager")) RS\
  2402. ins(2, "Do not view the translation in a terminal pager.") RS\
  2403. ins(1, ansi("bold", "-browser ") ansi("underline", "PROGRAM")) RS\
  2404. ins(2, "Specify the web browser to use.") RS\
  2405. ins(1, ansi("bold", "-no-browser")) RS\
  2406. ins(2, "Do not open the web browser.") RS\
  2407. RS "Networking options:" RS\
  2408. ins(1, ansi("bold", "-x ") ansi("underline", "HOST:PORT")\
  2409. ", " ansi("bold", "-proxy ") ansi("underline", "HOST:PORT")) RS\
  2410. ins(2, "Use HTTP proxy on given port.") RS\
  2411. ins(1, ansi("bold", "-u ") ansi("underline", "STRING")\
  2412. ", " ansi("bold", "-user-agent ") ansi("underline", "STRING")) RS\
  2413. ins(2, "Specify the User-Agent to identify as.") RS\
  2414. ins(1, ansi("bold", "-4") ", " ansi("bold", "-ipv4")\
  2415. ", " ansi("bold", "-inet4-only")) RS\
  2416. ins(2, "Connect only to IPv4 addresses.") RS\
  2417. ins(1, ansi("bold", "-6") ", " ansi("bold", "-ipv6")\
  2418. ", " ansi("bold", "-inet6-only")) RS\
  2419. ins(2, "Connect only to IPv6 addresses.") RS\
  2420. RS "Interactive shell options:" RS\
  2421. ins(1, ansi("bold", "-I") ", " ansi("bold", "-interactive") ", " ansi("bold", "-shell")) RS\
  2422. ins(2, "Start an interactive shell.") RS\
  2423. ins(1, ansi("bold", "-E") ", " ansi("bold", "-emacs")) RS\
  2424. ins(2, "Start the GNU Emacs front-end for an interactive shell.") RS\
  2425. ins(1, ansi("bold", "-no-rlwrap")) RS\
  2426. ins(2, "Do not invoke rlwrap when starting an interactive shell.") RS\
  2427. RS "I/O options:" RS\
  2428. ins(1, ansi("bold", "-i ") ansi("underline", "FILENAME")\
  2429. ", " ansi("bold", "-input ") ansi("underline", "FILENAME")) RS\
  2430. ins(2, "Specify the input file.") RS\
  2431. ins(1, ansi("bold", "-o ") ansi("underline", "FILENAME")\
  2432. ", " ansi("bold", "-output ") ansi("underline", "FILENAME")) RS\
  2433. ins(2, "Specify the output file.") RS\
  2434. RS "Language preference options:" RS\
  2435. ins(1, ansi("bold", "-l ") ansi("underline", "CODE")\
  2436. ", " ansi("bold", "-hl ") ansi("underline", "CODE")\
  2437. ", " ansi("bold", "-lang ") ansi("underline", "CODE")) RS\
  2438. ins(2, "Specify your home language.") RS\
  2439. ins(1, ansi("bold", "-s ") ansi("underline", "CODES")\
  2440. ", " ansi("bold", "-sl ") ansi("underline", "CODES")\
  2441. ", " ansi("bold", "-source ") ansi("underline", "CODES")\
  2442. ", " ansi("bold", "-from ") ansi("underline", "CODES")) RS\
  2443. ins(2, "Specify the source language(s), joined by '+'.") RS\
  2444. ins(1, ansi("bold", "-t ") ansi("underline", "CODES")\
  2445. ", " ansi("bold", "-tl ") ansi("underline", "CODES")\
  2446. ", " ansi("bold", "-target ") ansi("underline", "CODES")\
  2447. ", " ansi("bold", "-to ") ansi("underline", "CODES")) RS\
  2448. ins(2, "Specify the target language(s), joined by '+'.") RS\
  2449. RS "Text preprocessing options:" RS\
  2450. ins(1, ansi("bold", "-j") ", " ansi("bold", "-join-sentence")) RS\
  2451. ins(2, "Treat all arguments as one single sentence.") RS\
  2452. RS "Other options:" RS\
  2453. ins(1, ansi("bold", "-no-init")) RS\
  2454. ins(2, "Do not load any initialization script.") RS\
  2455. RS "See the man page " Command "(1) for more information."
  2456. }
  2457. function showMan( temp) {
  2458. if (ENVIRON["TRANS_MANPAGE"]) {
  2459. initPager()
  2460. Groff = detectProgram("groff", "--version")
  2461. if (Pager && Groff) {
  2462. temp = "echo -E \"${TRANS_MANPAGE}\""
  2463. temp = temp PIPE\
  2464. Groff " -Wall -mtty-char -mandoc -Tutf8 "\
  2465. "-rLL=" Option["width"] "n -rLT=" Option["width"] "n"
  2466. switch (Pager) {
  2467. case "less":
  2468. temp = temp PIPE\
  2469. Pager " -s -P\"\\ \\Manual page " Command "(1) line %lt (press h for help or q to quit)\""
  2470. break
  2471. case "most":
  2472. temp = temp PIPE Pager " -Cs"
  2473. break
  2474. default:
  2475. temp = temp PIPE Pager
  2476. }
  2477. system(temp)
  2478. return
  2479. }
  2480. }
  2481. if (fileExists(ENVIRON["TRANS_DIR"] "/man/" Command ".1"))
  2482. system("man " parameterize(ENVIRON["TRANS_DIR"] "/man/" Command ".1") SUPERR)
  2483. else if (system("man " Command SUPERR))
  2484. print getHelp()
  2485. }
  2486. function getReference(displayName,
  2487. code, col, cols, i, j, name, num, r, rows, saveSortedIn,
  2488. t1, t2) {
  2489. num = 0
  2490. for (code in Locale)
  2491. if (Locale[code]["support"] != "unstable")
  2492. num++
  2493. rows = int(num / 3) + (num % 3 ? 1 : 0)
  2494. cols[0][0] = cols[1][0] = cols[2][0] = NULLSTR
  2495. i = 0
  2496. saveSortedIn = PROCINFO["sorted_in"]
  2497. PROCINFO["sorted_in"] = displayName == "endonym" ? "@ind_num_asc" :
  2498. "compName"
  2499. for (code in Locale) {
  2500. if (Locale[code]["support"] != "unstable") {
  2501. col = int(i / rows)
  2502. append(cols[col], code)
  2503. i++
  2504. }
  2505. }
  2506. PROCINFO["sorted_in"] = saveSortedIn
  2507. if (displayName == "endonym") {
  2508. r = "┌" replicate("─", 23) "┬" replicate("─", 23) "┬" replicate("─", 23) "┐" RS
  2509. for (i = 0; i < rows; i++) {
  2510. r = r "│"
  2511. for (j = 0; j < 3; j++) {
  2512. if (cols[j][i]) {
  2513. t1 = getDisplay(cols[j][i])
  2514. switch (cols[j][i]) {
  2515. case "he":
  2516. t1 = sprintf(" %-18s", t1)
  2517. break
  2518. case "ur":
  2519. t1 = sprintf(" %-17s", t1)
  2520. break
  2521. case "hi": case "gu": case "km": case "kn":
  2522. case "my": case "ne": case "pa": case "si":
  2523. case "ta": case "te": case "yi":
  2524. t1 = sprintf(" %-16s", t1)
  2525. break
  2526. case "yue":
  2527. t1 = sprintf(" %-13s", t1)
  2528. break
  2529. case "ja": case "ko":
  2530. t1 = sprintf(" %-12s", t1)
  2531. break
  2532. case "zh-CN": case "zh-TW":
  2533. t1 = sprintf(" %-11s", t1)
  2534. break
  2535. default:
  2536. if (length(t1) <= 15)
  2537. t1 = sprintf(" %-15s", t1)
  2538. }
  2539. switch (length(cols[j][i])) {
  2540. case 1: case 2: case 3: case 4:
  2541. t2 = sprintf("- %s │", ansi("bold", sprintf("%4s", cols[j][i])))
  2542. break
  2543. case 5:
  2544. t2 = sprintf("- %s│", ansi("bold", cols[j][i]))
  2545. break
  2546. case 6:
  2547. t2 = sprintf("-%s│", ansi("bold", cols[j][i]))
  2548. break
  2549. case 7:
  2550. t2 = sprintf("-%s", ansi("bold", cols[j][i]))
  2551. break
  2552. default:
  2553. t2 = ansi("bold", cols[j][i])
  2554. }
  2555. r = r t1 t2
  2556. } else
  2557. r = r sprintf("%23s│", NULLSTR)
  2558. }
  2559. r = r RS
  2560. }
  2561. r = r "└" replicate("─", 23) "┴" replicate("─", 23) "┴" replicate("─", 23) "┘"
  2562. } else {
  2563. r = "┌" replicate("─", 23) "┬" replicate("─", 23) "┬" replicate("─", 23) "┐" RS
  2564. for (i = 0; i < rows; i++) {
  2565. r = r "│"
  2566. for (j = 0; j < 3; j++) {
  2567. if (cols[j][i]) {
  2568. t1 = getName(cols[j][i])
  2569. if (length(t1) > 15)
  2570. t1 = substr(t1, 1, 12) "..."
  2571. t1 = sprintf(" %-15s", t1)
  2572. switch (length(cols[j][i])) {
  2573. case 1: case 2: case 3: case 4:
  2574. t2 = sprintf("- %s │", ansi("bold", sprintf("%4s", cols[j][i])))
  2575. break
  2576. case 5:
  2577. t2 = sprintf("- %s│", ansi("bold", cols[j][i]))
  2578. break
  2579. case 6:
  2580. t2 = sprintf("-%s│", ansi("bold", cols[j][i]))
  2581. break
  2582. case 7:
  2583. t2 = sprintf("-%s", ansi("bold", cols[j][i]))
  2584. break
  2585. default:
  2586. t2 = ansi("bold", cols[j][i])
  2587. }
  2588. r = r t1 t2
  2589. } else
  2590. r = r sprintf("%23s│", NULLSTR)
  2591. }
  2592. r = r RS
  2593. }
  2594. r = r "└" replicate("─", 23) "┴" replicate("─", 23) "┴" replicate("─", 23) "┘"
  2595. }
  2596. return r
  2597. }
  2598. function getList(codes, code, i, r, saveSortedIn) {
  2599. r = NULLSTR
  2600. if (!isarray(codes))
  2601. r = getDetails(codes)
  2602. else if (anything(codes)) {
  2603. saveSortedIn = PROCINFO["sorted_in"]
  2604. PROCINFO["sorted_in"] = "@ind_num_asc"
  2605. for (i in codes)
  2606. r = (r ? r RS prettify("target-seperator", replicate(Option["chr-target-seperator"], Option["width"])) RS\
  2607. : r) getDetails(codes[i])
  2608. PROCINFO["sorted_in"] = saveSortedIn
  2609. } else
  2610. r = getDetails(Option["hl"])
  2611. return r
  2612. }
  2613. function tokenize(returnTokens, string,
  2614. delimiters,
  2615. newlines,
  2616. quotes,
  2617. escapeChars,
  2618. leftBlockComments,
  2619. rightBlockComments,
  2620. lineComments,
  2621. reservedOperators,
  2622. reservedPatterns,
  2623. blockCommenting,
  2624. c,
  2625. currentToken,
  2626. escaping,
  2627. i,
  2628. lineCommenting,
  2629. p,
  2630. quoting,
  2631. r,
  2632. s,
  2633. tempGroup,
  2634. tempPattern,
  2635. tempString) {
  2636. if (!delimiters[0]) {
  2637. delimiters[0] = " "
  2638. delimiters[1] = "\t"
  2639. delimiters[2] = "\v"
  2640. }
  2641. if (!newlines[0]) {
  2642. newlines[0] = "\n"
  2643. newlines[1] = "\r"
  2644. }
  2645. if (!quotes[0]) {
  2646. quotes[0] = "\""
  2647. }
  2648. if (!escapeChars[0]) {
  2649. escapeChars[0] = "\\"
  2650. }
  2651. if (!leftBlockComments[0]) {
  2652. leftBlockComments[0] = "#|"
  2653. leftBlockComments[1] = "/*"
  2654. leftBlockComments[2] = "(*"
  2655. }
  2656. if (!rightBlockComments[0]) {
  2657. rightBlockComments[0] = "|#"
  2658. rightBlockComments[1] = "*/"
  2659. rightBlockComments[2] = "*)"
  2660. }
  2661. if (!lineComments[0]) {
  2662. lineComments[0] = ";"
  2663. lineComments[1] = "//"
  2664. lineComments[2] = "#"
  2665. }
  2666. if (!reservedOperators[0]) {
  2667. reservedOperators[0] = "("
  2668. reservedOperators[1] = ")"
  2669. reservedOperators[2] = "["
  2670. reservedOperators[3] = "]"
  2671. reservedOperators[4] = "{"
  2672. reservedOperators[5] = "}"
  2673. reservedOperators[6] = ","
  2674. }
  2675. if (!reservedPatterns[0]) {
  2676. reservedPatterns[0] = "[+-]?((0|[1-9][0-9]*)|[.][0-9]*|(0|[1-9][0-9]*)[.][0-9]*)([Ee][+-]?[0-9]+)?"
  2677. reservedPatterns[1] = "[+-]?0[0-7]+([.][0-7]*)?"
  2678. reservedPatterns[2] = "[+-]?0[Xx][0-9A-Fa-f]+([.][0-9A-Fa-f]*)?"
  2679. }
  2680. split(string, s, "")
  2681. currentToken = ""
  2682. quoting = escaping = blockCommenting = lineCommenting = 0
  2683. p = 0
  2684. i = 1
  2685. while (i <= length(s)) {
  2686. c = s[i]
  2687. r = substr(string, i)
  2688. if (blockCommenting) {
  2689. if (tempString = startsWithAny(r, rightBlockComments))
  2690. blockCommenting = 0
  2691. i++
  2692. } else if (lineCommenting) {
  2693. if (belongsTo(c, newlines))
  2694. lineCommenting = 0
  2695. i++
  2696. } else if (quoting) {
  2697. currentToken = currentToken c
  2698. if (escaping) {
  2699. escaping = 0
  2700. } else {
  2701. if (belongsTo(c, quotes)) {
  2702. if (currentToken) {
  2703. returnTokens[p++] = currentToken
  2704. currentToken = ""
  2705. }
  2706. quoting = 0
  2707. } else if (belongsTo(c, escapeChars)) {
  2708. escaping = 1
  2709. } else {
  2710. }
  2711. }
  2712. i++
  2713. } else {
  2714. if (belongsTo(c, delimiters) || belongsTo(c, newlines)) {
  2715. if (currentToken) {
  2716. returnTokens[p++] = currentToken
  2717. currentToken = ""
  2718. }
  2719. i++
  2720. } else if (belongsTo(c, quotes)) {
  2721. if (currentToken) {
  2722. returnTokens[p++] = currentToken
  2723. }
  2724. currentToken = c
  2725. quoting = 1
  2726. i++
  2727. } else if (tempString = startsWithAny(r, leftBlockComments)) {
  2728. if (currentToken) {
  2729. returnTokens[p++] = currentToken
  2730. currentToken = ""
  2731. }
  2732. blockCommenting = 1
  2733. i += length(tempString)
  2734. } else if (tempString = startsWithAny(r, lineComments)) {
  2735. if (currentToken) {
  2736. returnTokens[p++] = currentToken
  2737. currentToken = ""
  2738. }
  2739. lineCommenting = 1
  2740. i += length(tempString)
  2741. } else if (tempString = startsWithAny(r, reservedOperators)) {
  2742. if (currentToken) {
  2743. returnTokens[p++] = currentToken
  2744. currentToken = ""
  2745. }
  2746. returnTokens[p++] = tempString
  2747. i += length(tempString)
  2748. } else if (tempPattern = matchesAny(r, reservedPatterns)) {
  2749. if (currentToken) {
  2750. returnTokens[p++] = currentToken
  2751. currentToken = ""
  2752. }
  2753. match(r, "^" tempPattern, tempGroup)
  2754. returnTokens[p++] = tempGroup[0]
  2755. i += length(tempGroup[0])
  2756. } else {
  2757. currentToken = currentToken c
  2758. i++
  2759. }
  2760. }
  2761. }
  2762. if (currentToken)
  2763. returnTokens[p++] = currentToken
  2764. }
  2765. function parseJsonArray(returnAST, tokens,
  2766. leftBrackets,
  2767. rightBrackets,
  2768. separators,
  2769. i, j, key, p, stack, token) {
  2770. if (!leftBrackets[0]) {
  2771. leftBrackets[0] = "("
  2772. leftBrackets[1] = "["
  2773. leftBrackets[2] = "{"
  2774. }
  2775. if (!rightBrackets[0]) {
  2776. rightBrackets[0] = ")"
  2777. rightBrackets[1] = "]"
  2778. rightBrackets[2] = "}"
  2779. }
  2780. if (!separators[0]) {
  2781. separators[0] = ","
  2782. }
  2783. stack[p = 0] = 0
  2784. for (i = 0; i < length(tokens); i++) {
  2785. token = tokens[i]
  2786. if (belongsTo(token, leftBrackets))
  2787. stack[++p] = 0
  2788. else if (belongsTo(token, rightBrackets))
  2789. --p
  2790. else if (belongsTo(token, separators))
  2791. stack[p]++
  2792. else {
  2793. key = stack[0]
  2794. for (j = 1; j <= p; j++)
  2795. key = key SUBSEP stack[j]
  2796. returnAST[key] = token
  2797. }
  2798. }
  2799. }
  2800. function parseJson(returnAST, tokens,
  2801. arrayStartTokens, arrayEndTokens,
  2802. objectStartTokens, objectEndTokens,
  2803. commas, colons,
  2804. flag, i, j, key, name, p, stack, token) {
  2805. if (!arrayStartTokens[0]) arrayStartTokens[0] = "["
  2806. if (!arrayEndTokens[0]) arrayEndTokens[0] = "]"
  2807. if (!objectStartTokens[0]) objectStartTokens[0] = "{"
  2808. if (!objectEndTokens[0]) objectEndTokens[0] = "}"
  2809. if (!commas[0]) commas[0] = ","
  2810. if (!colons[0]) colons[0] = ":"
  2811. stack[p = 0] = 0
  2812. flag = 0
  2813. for (i = 0; i < length(tokens); i++) {
  2814. token = tokens[i]
  2815. if (belongsTo(token, arrayStartTokens)) {
  2816. stack[++p] = 0
  2817. } else if (belongsTo(token, objectStartTokens)) {
  2818. stack[++p] = NULLSTR
  2819. flag = 0
  2820. } else if (belongsTo(token, objectEndTokens) ||
  2821. belongsTo(token, arrayEndTokens)) {
  2822. --p
  2823. } else if (belongsTo(token, commas)) {
  2824. if (isnum(stack[p]))
  2825. stack[p]++
  2826. else
  2827. flag = 0
  2828. } else if (belongsTo(token, colons)) {
  2829. flag = 1
  2830. } else if (isnum(stack[p]) || flag) {
  2831. key = stack[0]
  2832. for (j = 1; j <= p; j++)
  2833. key = key SUBSEP stack[j]
  2834. returnAST[key] = token
  2835. flag = 0
  2836. } else {
  2837. stack[p] = unparameterize(token)
  2838. }
  2839. }
  2840. }
  2841. function parseList(returnAST, tokens,
  2842. leftBrackets,
  2843. rightBrackets,
  2844. separators,
  2845. i, j, key, p, stack, token) {
  2846. if (!leftBrackets[0]) {
  2847. leftBrackets[0] = "("
  2848. leftBrackets[1] = "["
  2849. leftBrackets[2] = "{"
  2850. }
  2851. if (!rightBrackets[0]) {
  2852. rightBrackets[0] = ")"
  2853. rightBrackets[1] = "]"
  2854. rightBrackets[2] = "}"
  2855. }
  2856. if (!separators[0]) {
  2857. separators[0] = ","
  2858. }
  2859. stack[p = 0] = 0
  2860. for (i = 0; i < length(tokens); i++) {
  2861. token = tokens[i]
  2862. if (belongsTo(token, leftBrackets)) {
  2863. stack[++p] = 0
  2864. } else if (belongsTo(token, rightBrackets)) {
  2865. stack[--p]++
  2866. } else if (belongsTo(token, separators)) {
  2867. } else {
  2868. key = NULLSTR
  2869. if (p > 0) {
  2870. for (j = 0; j < p - 1; j++)
  2871. key = key SUBSEP stack[j]
  2872. returnAST[key][stack[p - 1]] = NULLSTR
  2873. key = key SUBSEP stack[p - 1]
  2874. }
  2875. returnAST[key][stack[p]] = token
  2876. stack[p]++
  2877. }
  2878. }
  2879. }
  2880. function prettify(name, string, i, temp) {
  2881. temp = string
  2882. if ("sgr-" name in Option)
  2883. if (isarray(Option["sgr-" name]))
  2884. for (i in Option["sgr-" name])
  2885. temp = ansi(Option["sgr-" name][i], temp)
  2886. else
  2887. temp = ansi(Option["sgr-" name], temp)
  2888. return temp
  2889. }
  2890. function randomColor( i) {
  2891. i = int(5 * rand())
  2892. switch (i) {
  2893. case 0: return "green"
  2894. case 1: return "yellow"
  2895. case 2: return "blue"
  2896. case 3: return "magenta"
  2897. case 4: return "cyan"
  2898. default: return "default"
  2899. }
  2900. }
  2901. function setRandomTheme( i, n, temp) {
  2902. srand(systime())
  2903. for (i = 0; i < 3; i++) {
  2904. do temp = randomColor(); while (belongsTo(temp, n))
  2905. n[i] = temp
  2906. }
  2907. Option["sgr-prompt-message"] = Option["sgr-languages"] = n[0]
  2908. Option["sgr-original-dictionary-detailed-word-class"][1] = n[0]
  2909. Option["sgr-original-dictionary-detailed-word-class"][2] = "bold"
  2910. Option["sgr-original-dictionary-synonyms"] = n[0]
  2911. Option["sgr-original-dictionary-synonyms-word-class"][1] = n[0]
  2912. Option["sgr-original-dictionary-synonyms-word-class"][2] = "bold"
  2913. Option["sgr-original-dictionary-examples"] = n[0]
  2914. Option["sgr-original-dictionary-see-also"] = n[0]
  2915. Option["sgr-dictionary-word-class"][1] = n[0]
  2916. Option["sgr-dictionary-word-class"][2] = "bold"
  2917. Option["sgr-original"][1] = Option["sgr-original-phonetics"][1] = n[1]
  2918. Option["sgr-original"][2] = Option["sgr-original-phonetics"][2] = "bold"
  2919. Option["sgr-prompt-message-original"][1] = n[1]
  2920. Option["sgr-prompt-message-original"][2] = "bold"
  2921. Option["sgr-languages-sl"] = n[1]
  2922. Option["sgr-original-dictionary-detailed-explanation"][1] = n[1]
  2923. Option["sgr-original-dictionary-detailed-explanation"][2] = "bold"
  2924. Option["sgr-original-dictionary-detailed-example"] = n[1]
  2925. Option["sgr-original-dictionary-detailed-synonyms"] = n[1]
  2926. Option["sgr-original-dictionary-detailed-synonyms-item"][1] = n[1]
  2927. Option["sgr-original-dictionary-detailed-synonyms-item"][2] = "bold"
  2928. Option["sgr-original-dictionary-synonyms-synonyms"] = n[1]
  2929. Option["sgr-original-dictionary-synonyms-synonyms-item"][1] = n[1]
  2930. Option["sgr-original-dictionary-synonyms-synonyms-item"][2] = "bold"
  2931. Option["sgr-original-dictionary-examples-example"] = n[1]
  2932. Option["sgr-original-dictionary-examples-original"][1] = n[1]
  2933. Option["sgr-original-dictionary-examples-original"][2] = "bold"
  2934. Option["sgr-original-dictionary-examples-original"][3] = "underline"
  2935. Option["sgr-original-dictionary-see-also-phrases"] = n[1]
  2936. Option["sgr-original-dictionary-see-also-phrases-item"][1] = n[1]
  2937. Option["sgr-original-dictionary-see-also-phrases-item"][2] = "bold"
  2938. Option["sgr-dictionary-explanation"] = n[1]
  2939. Option["sgr-dictionary-explanation-item"][1] = n[1]
  2940. Option["sgr-dictionary-explanation-item"][2] = "bold"
  2941. Option["sgr-alternatives-original"][1] = n[1]
  2942. Option["sgr-alternatives-original"][2] = "bold"
  2943. Option["sgr-translation"][1] = Option["sgr-translation-phonetics"][1] = n[2]
  2944. Option["sgr-translation"][2] = Option["sgr-translation-phonetics"][2] = "bold"
  2945. Option["sgr-languages-tl"] = n[2]
  2946. Option["sgr-dictionary-word"][1] = n[2]
  2947. Option["sgr-dictionary-word"][2] = "bold"
  2948. Option["sgr-alternatives-translations"] = n[2]
  2949. Option["sgr-alternatives-translations-item"][1] = n[2]
  2950. Option["sgr-alternatives-translations-item"][2] = "bold"
  2951. Option["sgr-brief-translation"][1] = Option["sgr-brief-translation-phonetics"][1] = n[2]
  2952. Option["sgr-brief-translation"][2] = Option["sgr-brief-translation-phonetics"][2] = "bold"
  2953. Option["fmt-welcome-message"] = Name
  2954. Option["sgr-welcome-message"][1] = n[0]
  2955. Option["sgr-welcome-message"][2] = "bold"
  2956. Option["fmt-welcome-submessage"] = "(:q to quit)"
  2957. Option["sgr-welcome-submessage"] = n[0]
  2958. Option["fmt-prompt"] = "%s> "
  2959. Option["sgr-prompt"][1] = n[1]
  2960. Option["sgr-prompt"][2] = "bold"
  2961. }
  2962. function setDefaultTheme() {
  2963. Option["sgr-translation"] = Option["sgr-translation-phonetics"] = "bold"
  2964. Option["sgr-prompt-message-original"] = "underline"
  2965. Option["sgr-languages-sl"] = "underline"
  2966. Option["sgr-languages-tl"] = "bold"
  2967. Option["sgr-original-dictionary-detailed-explanation"] = "bold"
  2968. Option["sgr-original-dictionary-detailed-synonyms-item"] = "bold"
  2969. Option["sgr-original-dictionary-synonyms-synonyms-item"] = "bold"
  2970. Option["sgr-original-dictionary-examples-original"][1] = "bold"
  2971. Option["sgr-original-dictionary-examples-original"][2] = "underline"
  2972. Option["sgr-original-dictionary-see-also-phrases-item"] = "bold"
  2973. Option["sgr-dictionary-word"] = "bold"
  2974. Option["sgr-alternatives-original"] = "underline"
  2975. Option["sgr-alternatives-translations-item"] = "bold"
  2976. Option["fmt-welcome-message"] = Name
  2977. Option["sgr-welcome-message"] = "bold"
  2978. Option["fmt-welcome-submessage"] = "(:q to quit)"
  2979. Option["fmt-prompt"] = "%s> "
  2980. Option["sgr-prompt"] = "bold"
  2981. }
  2982. function setTheme( file, line, script) {
  2983. if (Option["theme"] && Option["theme"] != "default"\
  2984. && Option["theme"] != "none" && Option["theme"] != "random") {
  2985. file = Option["theme"]
  2986. if (!fileExists(file)) {
  2987. file = ENVIRON["HOME"] "/.translate-shell/" Option["theme"]
  2988. if (!fileExists(file)) {
  2989. file = ENVIRON["HOME"] "/.config/translate-shell/" Option["theme"]
  2990. if (!fileExists(file)) return
  2991. }
  2992. }
  2993. }
  2994. if (file && fileExists(file)) {
  2995. script = NULLSTR
  2996. while (getline line < file)
  2997. script = script "\n" line
  2998. loadOptions(script)
  2999. } else if (Option["theme"] == "none")
  3000. ;
  3001. else if (Option["theme"] == "random")
  3002. setRandomTheme()
  3003. else
  3004. setDefaultTheme()
  3005. }
  3006. function provides(engineName) {
  3007. Translator[tolower(engineName)] = TRUE
  3008. }
  3009. function engineMethod(methodName, engine, translator) {
  3010. if (!Translator[Option["engine"]]) {
  3011. engine = tolower(Option["engine"])
  3012. if (!Translator[engine])
  3013. for (translator in Translator)
  3014. if (Translator[translator] &&
  3015. translator ~ "^"engine) {
  3016. engine = translator
  3017. break
  3018. }
  3019. if (!Translator[engine]) {
  3020. e("[ERROR] Translator not found: " Option["engine"] "\n"\
  3021. " Run '-list-engines / -S' to see a list of available engines.")
  3022. exit 1
  3023. }
  3024. Option["engine"] = engine
  3025. }
  3026. return Option["engine"] methodName
  3027. }
  3028. function initAudioPlayer() {
  3029. AudioPlayer = !system("mpv" SUPOUT SUPERR) ?
  3030. "mpv --no-config" :
  3031. (!system("mplayer" SUPOUT SUPERR) ?
  3032. "mplayer" :
  3033. (!system("mpg123 --version" SUPOUT SUPERR) ?
  3034. "mpg123" :
  3035. ""))
  3036. }
  3037. function initSpeechSynthesizer() {
  3038. SpeechSynthesizer = !system("say ''" SUPOUT SUPERR) ?
  3039. "say" :
  3040. (!system("espeak ''" SUPOUT SUPERR) ?
  3041. "espeak" :
  3042. "")
  3043. }
  3044. function initPager() {
  3045. Pager = !system("less -V" SUPOUT SUPERR) ?
  3046. "less" :
  3047. (!system("more -V" SUPOUT SUPERR) ?
  3048. "more" :
  3049. (!system("most" SUPOUT SUPERR) ?
  3050. "most" :
  3051. ""))
  3052. }
  3053. function initHttpService( inet) {
  3054. _Init()
  3055. inet = "inet"
  3056. if (Option["ip-version"])
  3057. inet = inet Option["ip-version"]
  3058. if (Option["proxy"]) {
  3059. match(Option["proxy"], /^(http:\/*)?(([^:]+):([^@]+)@)?([^\/]*):([^\/:]*)/, HttpProxySpec)
  3060. HttpAuthUser = HttpProxySpec[3]
  3061. HttpAuthPass = HttpProxySpec[4]
  3062. HttpAuthCredentials = base64(unquote(HttpAuthUser) ":" HttpAuthPass)
  3063. HttpService = "/" inet "/tcp/0/" HttpProxySpec[5] "/" HttpProxySpec[6]
  3064. HttpPathPrefix = HttpProtocol HttpHost
  3065. } else {
  3066. HttpService = "/" inet "/tcp/0/" HttpHost "/" HttpPort
  3067. HttpPathPrefix = ""
  3068. }
  3069. PROCINFO[HttpService, "READ_TIMEOUT"] = 2000
  3070. }
  3071. function preprocess(text) {
  3072. return quote(text)
  3073. }
  3074. function preprocessByDump(text, arr, len, temp) {
  3075. len = dumpX(text, arr)
  3076. temp = ""
  3077. for (i = 1; i <= len; i++)
  3078. temp = temp "%" arr[i]
  3079. return temp
  3080. }
  3081. function postprocess(text) {
  3082. text = gensub(/ ([.,;:?!"])/, "\\1", "g", text)
  3083. text = gensub(/(["]) /, "\\1", "g", text)
  3084. return text
  3085. }
  3086. function getResponse(text, sl, tl, hl,
  3087. content, header, isBody, url, group, status, location) {
  3088. url = _RequestUrl(text, sl, tl, hl)
  3089. header = "GET " url " HTTP/1.1\r\n"\
  3090. "Host: " HttpHost "\r\n"\
  3091. "Connection: close\r\n"
  3092. if (Option["user-agent"])
  3093. header = header "User-Agent: " Option["user-agent"] "\r\n"
  3094. if (Cookie)
  3095. header = header "Cookie: " Cookie "\r\n"
  3096. if (HttpAuthUser && HttpAuthPass)
  3097. header = header "Proxy-Authorization: Basic " HttpAuthCredentials "\r\n"
  3098. content = NULLSTR; isBody = 0
  3099. while (1) {
  3100. print header |& HttpService
  3101. while ((HttpService |& getline) > 0) {
  3102. if (isBody)
  3103. content = content ? content "\n" $0 : $0
  3104. else if (length($0) <= 1)
  3105. isBody = 1
  3106. else {
  3107. match($0, /^HTTP[^ ]* ([^ ]*)/, group)
  3108. if (RSTART) status = group[1]
  3109. match($0, /^Location: (.*)/, group)
  3110. if (RSTART) location = squeeze(group[1])
  3111. }
  3112. l(sprintf("%4s bytes > %s", length($0), $0))
  3113. }
  3114. close(HttpService)
  3115. if (ERRNO == "Connection timed out") {
  3116. w("[WARNING] " ERRNO ". Retrying IPv4 connection.")
  3117. Option["ip-version"] = 4
  3118. initHttpService()
  3119. PROCINFO[HttpService, "READ_TIMEOUT"] = 0
  3120. ERRNO = ""
  3121. } else
  3122. break
  3123. }
  3124. if ((status == "301" || status == "302") && location)
  3125. content = curl(location)
  3126. return assert(content, "[ERROR] Null response.")
  3127. }
  3128. function postResponse(text, sl, tl, hl, type,
  3129. content, contentLength, contentType, group,
  3130. header, isBody, reqBody, url, status, location, userAgent) {
  3131. url = _PostRequestUrl(text, sl, tl, hl, type)
  3132. contentType = _PostRequestContentType(text, sl, tl, hl, type)
  3133. userAgent = _PostRequestUserAgent(text, sl, tl, hl, type)
  3134. reqBody = _PostRequestBody(text, sl, tl, hl, type)
  3135. if (DumpContentengths[reqBody])
  3136. contentLength = DumpContentengths[reqBody]
  3137. else
  3138. contentLength = DumpContentengths[reqBody] = dump(reqBody, group)
  3139. header = "POST " url " HTTP/1.1\r\n"\
  3140. "Host: " HttpHost "\r\n"\
  3141. "Connection: close\r\n"\
  3142. "Content-Length: " contentLength "\r\n"\
  3143. "Content-Type: " contentType "\r\n"
  3144. if (Option["user-agent"] && !userAgent)
  3145. header = header "User-Agent: " Option["user-agent"] "\r\n"
  3146. if (userAgent)
  3147. header = header "User-Agent: " userAgent "\r\n"
  3148. if (Cookie)
  3149. header = header "Cookie: " Cookie "\r\n"
  3150. if (HttpAuthUser && HttpAuthPass)
  3151. header = header "Proxy-Authorization: Basic " HttpAuthCredentials "\r\n"
  3152. content = NULLSTR; isBody = 0
  3153. while (1) {
  3154. print (header "\r\n" reqBody) |& HttpService
  3155. while ((HttpService |& getline) > 0) {
  3156. if (isBody)
  3157. content = content ? content "\n" $0 : $0
  3158. else if (length($0) <= 1)
  3159. isBody = 1
  3160. else {
  3161. match($0, /^HTTP[^ ]* ([^ ]*)/, group)
  3162. if (RSTART) status = group[1]
  3163. match($0, /^Location: (.*)/, group)
  3164. if (RSTART) location = squeeze(group[1])
  3165. }
  3166. l(sprintf("%4s bytes > %s", length($0), $0))
  3167. }
  3168. close(HttpService)
  3169. if (ERRNO == "Connection timed out") {
  3170. w("[WARNING] " ERRNO ". Retrying IPv4 connection.")
  3171. Option["ip-version"] = 4
  3172. initHttpService()
  3173. PROCINFO[HttpService, "READ_TIMEOUT"] = 0
  3174. ERRNO = ""
  3175. } else
  3176. break
  3177. }
  3178. if (status == "404") {
  3179. e("[ERROR] 404 Not Found")
  3180. exit 1
  3181. }
  3182. if ((status == "301" || status == "302") && location) {
  3183. url = "https" substr(url, 5)
  3184. content = curlPost(url, reqBody)
  3185. }
  3186. return content
  3187. }
  3188. function p(string) {
  3189. if (Option["view"]) {
  3190. print string | Option["pager"]
  3191. close(Option["pager"])
  3192. } else
  3193. print string > Option["output"]
  3194. }
  3195. function play(text, tl, url, status) {
  3196. url = _TTSUrl(text, tl)
  3197. status = system(Option["player"] " " parameterize(url) SUPOUT SUPERR)
  3198. if (status)
  3199. w("Voice output isn't available for " getName(tl))
  3200. return status
  3201. }
  3202. function download_audio(text, tl, url, output) {
  3203. url = _TTSUrl(text, tl)
  3204. if (Option["download-audio-as"])
  3205. output = Option["download-audio-as"]
  3206. else
  3207. output = text " [" Option["engine"] "] (" Option["narrator"] ").ts"
  3208. if (url ~ /^\//)
  3209. system("mv -- " parameterize(url) " " parameterize(output))
  3210. else
  3211. curl(url, output)
  3212. }
  3213. function getTranslation(text, sl, tl, hl,
  3214. isVerbose, toSpeech, returnPlaylist, returnIl) {
  3215. return _Translate(text, sl, tl, hl,
  3216. isVerbose, toSpeech, returnPlaylist, returnIl)
  3217. }
  3218. function fileTranslation(uri, group, temp1, temp2) {
  3219. temp1 = Option["input"]
  3220. temp2 = Option["verbose"]
  3221. match(uri, /^file:\/\/(.*)/, group)
  3222. Option["input"] = group[1]
  3223. Option["verbose"] = 0
  3224. translateMain()
  3225. Option["input"] = temp1
  3226. Option["verbose"] = temp2
  3227. }
  3228. function webTranslation(uri, sl, tl, hl, temp) {
  3229. temp = _WebTranslateUrl(uri, sl, tl, hl)
  3230. if (temp) {
  3231. p(temp)
  3232. if (Option["browser"] != NONE)
  3233. system(Option["browser"] " " parameterize(temp) SUPOUT SUPERR)
  3234. }
  3235. }
  3236. function translate(text, inline,
  3237. i, j, playlist, il, saveSortedIn) {
  3238. if (!getCode(Option["hl"])) {
  3239. w("[WARNING] Unknown language code: " Option["hl"] ", fallback to English: en")
  3240. Option["hl"] = "en"
  3241. } else if (isRTL(Option["hl"])) {
  3242. if (!FriBidi)
  3243. w("[WARNING] " getName(Option["hl"]) " is a right-to-left language, but FriBidi is not found.")
  3244. }
  3245. if (!getCode(Option["sl"])) {
  3246. w("[WARNING] Unknown source language code: " Option["sl"])
  3247. } else if (isRTL(Option["sl"])) {
  3248. if (!FriBidi)
  3249. w("[WARNING] " getName(Option["sl"]) " is a right-to-left language, but FriBidi is not found.")
  3250. }
  3251. saveSortedIn = PROCINFO["sorted_in"]
  3252. PROCINFO["sorted_in"] = "@ind_num_asc"
  3253. for (i in Option["tl"]) {
  3254. if (!Option["interactive"])
  3255. if (Option["verbose"] && i > 1)
  3256. p(prettify("target-seperator", replicate(Option["chr-target-seperator"], Option["width"])))
  3257. if (inline &&
  3258. startsWithAny(text, UriSchemes) == "file://") {
  3259. fileTranslation(text)
  3260. } else if (inline &&
  3261. startsWithAny(text, UriSchemes) == "http://" ||
  3262. startsWithAny(text, UriSchemes) == "https://") {
  3263. webTranslation(text, Option["sl"], Option["tl"][i], Option["hl"])
  3264. } else {
  3265. if (!Option["no-translate"])
  3266. p(getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"] || Option["download-audio"], playlist, il))
  3267. else
  3268. il[0] = Option["sl"] == "auto" ? "en" : Option["sl"]
  3269. if (Option["play"] == 1) {
  3270. if (Option["player"])
  3271. for (j in playlist)
  3272. play(playlist[j]["text"], playlist[j]["tl"])
  3273. else if (SpeechSynthesizer)
  3274. for (j in playlist)
  3275. print playlist[j]["text"] | SpeechSynthesizer
  3276. } else if (Option["play"] == 2) {
  3277. if (Option["player"])
  3278. play(text, il[0])
  3279. else if (SpeechSynthesizer)
  3280. print text | SpeechSynthesizer
  3281. }
  3282. if (Option["download-audio"] == 1) {
  3283. if (Option["play"] != 2 && !Option["no-translate"])
  3284. download_audio(playlist[length(playlist) - 1]["text"],\
  3285. playlist[length(playlist) - 1]["tl"])
  3286. else
  3287. download_audio(text, il[0])
  3288. }
  3289. }
  3290. }
  3291. PROCINFO["sorted_in"] = saveSortedIn
  3292. }
  3293. function translates(text, inline,
  3294. i) {
  3295. saveSortedIn = PROCINFO["sorted_in"]
  3296. PROCINFO["sorted_in"] = "@ind_num_asc"
  3297. for (i in Option["sls"]) {
  3298. if (!Option["interactive"])
  3299. if (Option["verbose"] && i > 1)
  3300. p(prettify("target-seperator", replicate(Option["chr-target-seperator"], Option["width"])))
  3301. Option["sl"] = Option["sls"][i]
  3302. translate(text, inline)
  3303. }
  3304. PROCINFO["sorted_in"] = saveSortedIn
  3305. }
  3306. function translateMain( i, line) {
  3307. if (Option["interactive"])
  3308. prompt()
  3309. if (Option["input"] == STDIN || fileExists(Option["input"])) {
  3310. i = 0
  3311. while (getline line < Option["input"])
  3312. if (line) {
  3313. if (!Option["interactive"])
  3314. if (Option["verbose"] && i++ > 0)
  3315. p(prettify("source-seperator",
  3316. replicate(Option["chr-source-seperator"],
  3317. Option["width"])))
  3318. if (Option["interactive"])
  3319. repl(line)
  3320. else
  3321. translates(line)
  3322. } else {
  3323. if (!Option["interactive"])
  3324. if (!Option["verbose"])
  3325. p(line)
  3326. }
  3327. } else
  3328. e("[ERROR] File not found: " Option["input"])
  3329. }
  3330. function _Init( vm) {
  3331. vm = engineMethod("Init")
  3332. return @vm()
  3333. }
  3334. function _RequestUrl(text, sl, tl, hl, vm) {
  3335. vm = engineMethod("RequestUrl")
  3336. return @vm(text, sl, tl, hl)
  3337. }
  3338. function _PostRequestUrl(text, sl, tl, hl, type, vm) {
  3339. vm = engineMethod("PostRequestUrl")
  3340. return @vm(text, sl, tl, hl, type)
  3341. }
  3342. function _PostRequestContentType(text, sl, tl, hl, type, vm) {
  3343. vm = engineMethod("PostRequestContentType")
  3344. return @vm(text, sl, tl, hl, type)
  3345. }
  3346. function _PostRequestUserAgent(text, sl, tl, hl, type, vm) {
  3347. vm = engineMethod("PostRequestUserAgent")
  3348. return @vm(text, sl, tl, hl, type)
  3349. }
  3350. function _PostRequestBody(text, sl, tl, hl, type, vm) {
  3351. vm = engineMethod("PostRequestBody")
  3352. return @vm(text, sl, tl, hl, type)
  3353. }
  3354. function _TTSUrl(text, tl, vm) {
  3355. vm = engineMethod("TTSUrl")
  3356. return @vm(text, tl)
  3357. }
  3358. function _WebTranslateUrl(uri, sl, tl, hl, vm) {
  3359. vm = engineMethod("WebTranslateUrl")
  3360. return @vm(uri, sl, tl, hl)
  3361. }
  3362. function _Translate(text, sl, tl, hl,
  3363. isVerbose, toSpeech, returnPlaylist, returnIl,
  3364. vm) {
  3365. vm = engineMethod("Translate")
  3366. return @vm(text, sl, tl, hl,
  3367. isVerbose, toSpeech, returnPlaylist, returnIl)
  3368. }
  3369. BEGIN { provides("google") }
  3370. function genRL(a, x,
  3371. b, c, d, i, y) {
  3372. tokenize(y, x)
  3373. parseList(b, y)
  3374. i = SUBSEP 0
  3375. for (c = 0; c < length(b[i]) - 2; c += 3) {
  3376. d = b[i][c + 2]
  3377. d = d >= 97 ? d - 87 :
  3378. d - 48
  3379. d = b[i][c + 1] == 43 ? rshift(a, d) : lshift(a, d)
  3380. a = b[i][c] == 43 ? and(a + d, 4294967295) : xor(a, d)
  3381. }
  3382. return a
  3383. }
  3384. function genTK(text,
  3385. a, d, dLen, e, tkk, ub, vb) {
  3386. if (TK[text]) return TK[text]
  3387. tkk = systime() / 3600
  3388. ub = "[43,45,51,94,43,98,43,45,102]"
  3389. vb = "[43,45,97,94,43,54]"
  3390. dLen = dump(text, d)
  3391. a = tkk
  3392. for (e = 1; e <= dLen; e++)
  3393. a = genRL(a + d[e], vb)
  3394. a = genRL(a, ub)
  3395. 0 > a && (a = and(a, 2147483647) + 2147483648)
  3396. a %= 1e6
  3397. TK[text] = a "." xor(a, tkk)
  3398. l(text, "text")
  3399. l(tkk, "tkk")
  3400. l(TK[text], "tk")
  3401. return TK[text]
  3402. }
  3403. function googleInit() {
  3404. HttpProtocol = "http://"
  3405. HttpHost = "translate.googleapis.com"
  3406. HttpPort = 80
  3407. }
  3408. function googleRequestUrl(text, sl, tl, hl, qc) {
  3409. qc = Option["no-autocorrect"] ? "qc" : "qca";
  3410. return HttpPathPrefix "/translate_a/single?client=gtx"\
  3411. "&ie=UTF-8&oe=UTF-8"\
  3412. "&dt=bd&dt=ex&dt=ld&dt=md&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=gt"\
  3413. "&dt=" qc "&sl=" sl "&tl=" tl "&hl=" hl\
  3414. "&q=" preprocessByDump(text)
  3415. }
  3416. function googleTTSUrl(text, tl) {
  3417. return HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=gtx"\
  3418. "&tl=" tl "&q=" preprocessByDump(text)
  3419. }
  3420. function googleWebTranslateUrl(uri, sl, tl, hl) {
  3421. return "https://translate.google.com/translate?"\
  3422. "hl=" hl "&sl=" sl "&tl=" tl "&u=" uri
  3423. }
  3424. function googleTranslate(text, sl, tl, hl,
  3425. isVerbose, toSpeech, returnPlaylist, returnIl,
  3426. r,
  3427. content, tokens, ast,
  3428. _sl, _tl, _hl, il, ils, isPhonetic,
  3429. article, example, explanation, ref, word,
  3430. translation, translations, phonetics,
  3431. wordClasses, words, segments, altTranslations,
  3432. original, oPhonetics, oWordClasses, oWords,
  3433. oRefs, oSynonymClasses, oSynonyms,
  3434. oExamples, oSeeAlso,
  3435. wShowOriginal, wShowOriginalPhonetics,
  3436. wShowTranslation, wShowTranslationPhonetics,
  3437. wShowPromptMessage, wShowLanguages,
  3438. wShowOriginalDictionary, wShowDictionary,
  3439. wShowAlternatives,
  3440. genderedTrans, hasWordClasses, hasAltTranslations,
  3441. i, j, k, group, temp, saveSortedIn) {
  3442. isPhonetic = match(tl, /^@/)
  3443. tl = substr(tl, 1 + isPhonetic)
  3444. if (!getCode(tl)) {
  3445. w("[WARNING] Unknown target language code: " tl)
  3446. } else if (isRTL(tl)) {
  3447. if (!FriBidi)
  3448. w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
  3449. }
  3450. _sl = getCode(sl); if (!_sl) _sl = sl
  3451. _tl = getCode(tl); if (!_tl) _tl = tl
  3452. _hl = getCode(hl); if (!_hl) _hl = hl
  3453. content = getResponse(text, _sl, _tl, _hl)
  3454. if (Option["dump"])
  3455. return content
  3456. tokenize(tokens, content)
  3457. parseJsonArray(ast, tokens)
  3458. l(content, "content", 1, 1)
  3459. l(tokens, "tokens", 1, 0, 1)
  3460. l(ast, "ast")
  3461. if (!isarray(ast) || !anything(ast)) {
  3462. e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
  3463. ExitCode = 1
  3464. return
  3465. }
  3466. saveSortedIn = PROCINFO["sorted_in"]
  3467. PROCINFO["sorted_in"] = "compareByIndexFields"
  3468. for (i in ast) {
  3469. if (ast[i] == "null") continue
  3470. if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "0$")
  3471. append(translations, literal(ast[i]))
  3472. if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "1$")
  3473. append(original, literal(ast[i]))
  3474. if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "2$")
  3475. append(phonetics, literal(ast[i]))
  3476. if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "3$")
  3477. append(oPhonetics, literal(ast[i]))
  3478. if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
  3479. wordClasses[group[1]] = literal(ast[i])
  3480. if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "([[:digit:]]+)$", group))
  3481. words[group[1]][group[2]][group[3]] = literal(ast[i])
  3482. if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)$", group))
  3483. words[group[1]][group[2]]["1"][group[3]] = literal(ast[i])
  3484. if (match(i, "^0" SUBSEP "5" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group)) {
  3485. segments[group[1]] = literal(ast[i])
  3486. altTranslations[group[1]][0] = ""
  3487. }
  3488. if (match(i, "^0" SUBSEP "5" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
  3489. altTranslations[group[1]][group[2]] = literal(ast[i])
  3490. if (i ~ "^0" SUBSEP "7" SUBSEP "5$") {
  3491. if (ast[i] == "true")
  3492. w("Showing translation for: (use -no-auto to disable autocorrect)")
  3493. else
  3494. w("Did you mean: "\
  3495. ansi("bold", unparameterize(ast["0" SUBSEP "7" SUBSEP "1"])))
  3496. }
  3497. if (i ~ "^0" SUBSEP "8" SUBSEP "0" SUBSEP "[[:digit:]]+$" ||
  3498. i ~ "^0" SUBSEP "2$")
  3499. append(ils, literal(ast[i]))
  3500. if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
  3501. oSynonymClasses[group[1]] = literal(ast[i])
  3502. if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
  3503. if (ast[i]) {
  3504. oRefs[literal(ast[i])][1] = group[1]
  3505. oRefs[literal(ast[i])][2] = group[2]
  3506. }
  3507. if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0" SUBSEP "([[:digit:]]+)$", group))
  3508. oSynonyms[group[1]][group[2]][group[3]] = literal(ast[i])
  3509. if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
  3510. oWordClasses[group[1]] = literal(ast[i])
  3511. if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
  3512. oWords[group[1]][group[2]][0] = literal(ast[i])
  3513. if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
  3514. oWords[group[1]][group[2]][1] = literal(ast[i])
  3515. if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2$", group))
  3516. oWords[group[1]][group[2]][2] = literal(ast[i])
  3517. if (match(i, "^0" SUBSEP "13" SUBSEP "0" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
  3518. oExamples[group[1]] = literal(ast[i])
  3519. if (match(i, "^0" SUBSEP "14" SUBSEP "0" SUBSEP "([[:digit:]]+)$", group))
  3520. oSeeAlso[group[1]] = literal(ast[i])
  3521. if (match(i, "^0" SUBSEP "18" SUBSEP "0" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
  3522. genderedTrans[group[1]] = literal(ast[i])
  3523. }
  3524. PROCINFO["sorted_in"] = saveSortedIn
  3525. translation = join(translations)
  3526. returnIl[0] = il = !anything(ils) || belongsTo(sl, ils) ? sl : ils[0]
  3527. if (Option["verbose"] < -1)
  3528. return il
  3529. else if (Option["verbose"] < 0)
  3530. return getList(il)
  3531. if (!isVerbose) {
  3532. r = isPhonetic && anything(phonetics) ?
  3533. prettify("brief-translation-phonetics", join(phonetics, " ")) :
  3534. prettify("brief-translation", s(translation, tl))
  3535. if (toSpeech) {
  3536. returnPlaylist[0]["text"] = translation
  3537. returnPlaylist[0]["tl"] = _tl
  3538. }
  3539. } else {
  3540. wShowOriginal = Option["show-original"]
  3541. wShowOriginalPhonetics = Option["show-original-phonetics"]
  3542. wShowTranslation = Option["show-translation"]
  3543. wShowTranslationPhonetics = Option["show-translation-phonetics"]
  3544. wShowPromptMessage = Option["show-prompt-message"]
  3545. wShowLanguages = Option["show-languages"]
  3546. wShowOriginalDictionary = Option["show-original-dictionary"]
  3547. wShowDictionary = Option["show-dictionary"]
  3548. wShowAlternatives = Option["show-alternatives"]
  3549. if (!anything(oPhonetics)) wShowOriginalPhonetics = 0
  3550. if (!anything(phonetics)) wShowTranslationPhonetics = 0
  3551. if (getCode(il) == getCode(tl) &&\
  3552. (isarray(oWordClasses) || isarray(oSynonymClasses) ||\
  3553. isarray(oExamples) || isarray(oSeeAlso))) {
  3554. wShowOriginalDictionary = 1
  3555. wShowTranslation = 0
  3556. }
  3557. hasWordClasses = exists(wordClasses)
  3558. hasAltTranslations = exists(altTranslations[0])
  3559. if (!hasWordClasses && !hasAltTranslations)
  3560. wShowPromptMessage = wShowLanguages = 0
  3561. if (!hasWordClasses) wShowDictionary = 0
  3562. if (!hasAltTranslations) wShowAlternatives = 0
  3563. if (wShowOriginal) {
  3564. if (r) r = r RS RS
  3565. r = r m("-- display original text & phonetics")
  3566. r = r prettify("original", s(join(original, " "), il))
  3567. if (wShowOriginalPhonetics)
  3568. r = r RS prettify("original-phonetics", showPhonetics(join(oPhonetics, " "), il))
  3569. }
  3570. if (wShowTranslation) {
  3571. if (r) r = r RS RS
  3572. r = r m("-- display major translation & phonetics")
  3573. if (!exists(genderedTrans))
  3574. r = r prettify("translation", s(translation, tl))
  3575. else {
  3576. r = r prettify("prompt-message", s("(♂) ", hl))
  3577. r = r prettify("translation", s(genderedTrans[0], tl)) RS
  3578. r = r prettify("prompt-message", s("(♀) ", hl))
  3579. r = r prettify("translation", s(genderedTrans[1], tl))
  3580. }
  3581. if (wShowTranslationPhonetics)
  3582. r = r RS prettify("translation-phonetics", showPhonetics(join(phonetics, " "), tl))
  3583. }
  3584. if (wShowPromptMessage || wShowLanguages)
  3585. if (r) r = r RS
  3586. if (wShowPromptMessage) {
  3587. if (hasWordClasses) {
  3588. if (r) r = r RS
  3589. r = r m("-- display prompt message (Definitions of ...)")
  3590. if (isRTL(hl))
  3591. r = r prettify("prompt-message", s(showDefinitionsOf(hl, join(original, " "))))
  3592. else {
  3593. split(showDefinitionsOf(hl, "\0%s\0"), group, "\0")
  3594. for (i = 1; i <= length(group); i++) {
  3595. if (group[i] == "%s")
  3596. r = r prettify("prompt-message-original", show(join(original, " "), il))
  3597. else
  3598. r = r prettify("prompt-message", group[i])
  3599. }
  3600. }
  3601. } else if (hasAltTranslations) {
  3602. if (r) r = r RS
  3603. r = r m("-- display prompt message (Translations of ...)")
  3604. if (isRTL(hl))
  3605. r = r prettify("prompt-message", s(showTranslationsOf(hl, join(original, " "))))
  3606. else {
  3607. split(showTranslationsOf(hl, "\0%s\0"), group, "\0")
  3608. for (i = 1; i <= length(group); i++) {
  3609. if (group[i] == "%s")
  3610. r = r prettify("prompt-message-original", show(join(original, " "), il))
  3611. else
  3612. r = r prettify("prompt-message", group[i])
  3613. }
  3614. }
  3615. }
  3616. }
  3617. if (wShowLanguages) {
  3618. if (r) r = r RS
  3619. r = r m("-- display source language -> target language")
  3620. temp = Option["fmt-languages"]
  3621. if (!temp) temp = "[ %s -> %t ]"
  3622. split(temp, group, /(%s|%S|%t|%T)/)
  3623. r = r prettify("languages", group[1])
  3624. if (temp ~ /%s/)
  3625. r = r prettify("languages-sl", getDisplay(il))
  3626. if (temp ~ /%S/)
  3627. r = r prettify("languages-sl", getName(il))
  3628. r = r prettify("languages", group[2])
  3629. if (temp ~ /%t/)
  3630. r = r prettify("languages-tl", getDisplay(tl))
  3631. if (temp ~ /%T/)
  3632. r = r prettify("languages-tl", getName(tl))
  3633. r = r prettify("languages", group[3])
  3634. }
  3635. if (wShowOriginalDictionary) {
  3636. if (exists(oWordClasses)) {
  3637. if (r) r = r RS
  3638. r = r m("-- display original dictionary (detailed explanations)")
  3639. for (i = 0; i < length(oWordClasses); i++) {
  3640. r = (i > 0 ? r RS : r) RS prettify("original-dictionary-detailed-word-class", s(oWordClasses[i], hl))
  3641. for (j = 0; j < length(oWords[i]); j++) {
  3642. explanation = oWords[i][j][0]
  3643. ref = oWords[i][j][1]
  3644. example = oWords[i][j][2]
  3645. r = (j > 0 ? r RS : r) RS prettify("original-dictionary-detailed-explanation", ins(1, explanation, il))
  3646. if (example)
  3647. r = r RS prettify("original-dictionary-detailed-example", ins(2, "- \"" example "\"", il))
  3648. if (ref && isarray(oRefs[ref])) {
  3649. temp = prettify("original-dictionary-detailed-synonyms", ins(1, show(showSynonyms(hl), hl) ": "))
  3650. temp = temp prettify("original-dictionary-detailed-synonyms-item", show(oSynonyms[oRefs[ref][1]][oRefs[ref][2]][0], il))
  3651. for (k = 1; k < length(oSynonyms[oRefs[ref][1]][oRefs[ref][2]]); k++)
  3652. temp = temp prettify("original-dictionary-detailed-synonyms", ", ")\
  3653. prettify("original-dictionary-detailed-synonyms-item", show(oSynonyms[oRefs[ref][1]][oRefs[ref][2]][k], il))
  3654. r = r RS temp
  3655. }
  3656. }
  3657. }
  3658. }
  3659. if (exists(oSynonymClasses)) {
  3660. r = r RS RS
  3661. r = r m("-- display original dictionary (synonyms)")
  3662. r = r prettify("original-dictionary-synonyms", s(showSynonyms(hl), hl))
  3663. for (i = 0; i < length(oSynonymClasses); i++) {
  3664. r = (i > 0 ? r RS : r) RS prettify("original-dictionary-synonyms-word-class", ins(1, oSynonymClasses[i], hl))
  3665. for (j = 0; j < length(oSynonyms[i]); j++) {
  3666. temp = prettify("original-dictionary-synonyms-synonyms", ins(2, "- "))
  3667. temp = temp prettify("original-dictionary-synonyms-synonyms-item", show(oSynonyms[i][j][0], il))
  3668. for (k = 1; k < length(oSynonyms[i][j]); k++)
  3669. temp = temp prettify("original-dictionary-synonyms-synonyms", ", ")\
  3670. prettify("original-dictionary-synonyms-synonyms-item", show(oSynonyms[i][j][k], il))
  3671. r = r RS temp
  3672. }
  3673. }
  3674. }
  3675. if (exists(oExamples)) {
  3676. r = r RS RS
  3677. r = r m("-- display original dictionary (examples)")
  3678. r = r prettify("original-dictionary-examples", s(showExamples(hl), hl))
  3679. for (i = 0; i < length(oExamples); i++) {
  3680. example = oExamples[i]
  3681. temp = prettify("original-dictionary-examples-example", ins(1, "- "))
  3682. split(example, group, /(<b>|<\/b>)/)
  3683. if (group[3] ~ / [[:punct:].]/)
  3684. group[3] = substr(group[3], 2)
  3685. if (isRTL(il))
  3686. temp = temp show(group[1] group[2] group[3], il)
  3687. else
  3688. temp = temp prettify("original-dictionary-examples-example", group[1])\
  3689. prettify("original-dictionary-examples-original", group[2])\
  3690. prettify("original-dictionary-examples-example", group[3])
  3691. r = (i > 0 ? r RS : r) RS temp
  3692. }
  3693. }
  3694. if (exists(oSeeAlso)) {
  3695. r = r RS RS
  3696. r = r m("-- display original dictionary (see also)")
  3697. r = r prettify("original-dictionary-see-also", s(showSeeAlso(hl), hl))
  3698. temp = ins(1, prettify("original-dictionary-see-also-phrases-item", show(oSeeAlso[0], il)))
  3699. for (k = 1; k < length(oSeeAlso); k++)
  3700. temp = temp prettify("original-dictionary-see-also-phrases", ", ")\
  3701. prettify("original-dictionary-see-also-phrases-item", show(oSeeAlso[k], il))
  3702. r = r RS temp
  3703. }
  3704. }
  3705. if (wShowDictionary) {
  3706. if (r) r = r RS
  3707. r = r m("-- display dictionary entries")
  3708. for (i = 0; i < length(wordClasses); i++) {
  3709. r = (i > 0 ? r RS : r) RS prettify("dictionary-word-class", s(wordClasses[i], hl))
  3710. for (j = 0; j < length(words[i]); j++) {
  3711. word = words[i][j][0]
  3712. article = words[i][j][4]
  3713. if (isRTL(il))
  3714. explanation = join(words[i][j][1], ", ")
  3715. else {
  3716. explanation = prettify("dictionary-explanation-item", words[i][j][1][0])
  3717. for (k = 1; k < length(words[i][j][1]); k++)
  3718. explanation = explanation prettify("dictionary-explanation", ", ")\
  3719. prettify("dictionary-explanation-item", words[i][j][1][k])
  3720. }
  3721. r = r RS prettify("dictionary-word", ins(1, (article ? "(" article ") " : "") word, tl))
  3722. if (isRTL(il))
  3723. r = r RS prettify("dictionary-explanation-item", ins(2, explanation, il))
  3724. else
  3725. r = r RS ins(2, explanation)
  3726. }
  3727. }
  3728. }
  3729. if (wShowAlternatives) {
  3730. if (r) r = r RS RS
  3731. r = r m("-- display alternative translations")
  3732. for (i = 0; i < length(altTranslations); i++) {
  3733. r = (i > 0 ? r RS : r) prettify("alternatives-original", show(segments[i], il))
  3734. if (isRTL(tl)) {
  3735. temp = join(altTranslations[i], ", ")
  3736. r = r RS prettify("alternatives-translations-item", ins(1, temp, tl))
  3737. } else {
  3738. temp = prettify("alternatives-translations-item", altTranslations[i][0])
  3739. for (j = 1; j < length(altTranslations[i]); j++)
  3740. temp = temp prettify("alternatives-translations", ", ")\
  3741. prettify("alternatives-translations-item", altTranslations[i][j])
  3742. r = r RS ins(1, temp)
  3743. }
  3744. }
  3745. }
  3746. if (toSpeech) {
  3747. if (index(showTranslationsOf(hl, "%s"), "%s") > 2) {
  3748. returnPlaylist[0]["text"] = showTranslationsOf(hl)
  3749. returnPlaylist[0]["tl"] = _hl
  3750. returnPlaylist[1]["text"] = join(original)
  3751. returnPlaylist[1]["tl"] = il
  3752. } else {
  3753. returnPlaylist[0]["text"] = join(original)
  3754. returnPlaylist[0]["tl"] = il
  3755. returnPlaylist[1]["text"] = showTranslationsOf(hl)
  3756. returnPlaylist[1]["tl"] = _hl
  3757. }
  3758. returnPlaylist[2]["text"] = translation
  3759. returnPlaylist[2]["tl"] = _tl
  3760. }
  3761. }
  3762. return r
  3763. }
  3764. BEGIN { provides("bing") }
  3765. function bingInit() {
  3766. HttpProtocol = "http://"
  3767. HttpHost = "www.bing.com"
  3768. HttpPort = 80
  3769. }
  3770. function bingSetIG( content, cookie, group, header, isBody,
  3771. url, status, location) {
  3772. url = HttpPathPrefix "/translator"
  3773. header = "GET " url " HTTP/1.1\r\n"\
  3774. "Host: " HttpHost "\r\n"\
  3775. "Connection: close\r\n"
  3776. if (Option["user-agent"])
  3777. header = header "User-Agent: " Option["user-agent"] "\r\n"
  3778. cookie = NULLSTR
  3779. print header |& HttpService
  3780. while ((HttpService |& getline) > 0) {
  3781. match($0, /Set-Cookie: ([^;]*);/, group)
  3782. if (group[1]) {
  3783. cookie = cookie (cookie ? "; " : NULLSTR) group[1]
  3784. }
  3785. if (isBody)
  3786. content = content ? content "\n" $0 : $0
  3787. else if (length($0) <= 1)
  3788. isBody = 1
  3789. else {
  3790. match($0, /^HTTP[^ ]* ([^ ]*)/, group)
  3791. if (RSTART) status = group[1]
  3792. match($0, /^Location: (.*)/, group)
  3793. if (RSTART) location = squeeze(group[1])
  3794. }
  3795. l(sprintf("%4s bytes > %s", length($0), length($0) < 1024 ? $0 : "..."))
  3796. }
  3797. close(HttpService)
  3798. if ((status == "301" || status == "302") && location)
  3799. content = curl(location)
  3800. Cookie = cookie
  3801. match(content, /IG:"([^"]+)"/, group)
  3802. if (group[1]) {
  3803. IG = group[1]
  3804. } else {
  3805. e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
  3806. exit 1
  3807. }
  3808. }
  3809. function bingTTSUrl(text, tl,
  3810. country, gender, i, group,
  3811. header, content, isBody) {
  3812. gender = "female"
  3813. country = NULLSTR
  3814. split(Option["narrator"], group, ",")
  3815. for (i in group) {
  3816. if (group[i] ~ /^(f(emale)?|w(oman)?)$/)
  3817. gender = "female"
  3818. else if (group[i] ~ /^m(ale|an)?$/)
  3819. gender = "male"
  3820. else
  3821. country = group[i]
  3822. }
  3823. if (country) tl = tl "-" country
  3824. else if (tl == "ar") tl = tl "-EG"
  3825. else if (tl == "da") tl = tl "-DK"
  3826. else if (tl == "de") tl = tl "-DE"
  3827. else if (tl == "en") tl = tl "-US"
  3828. else if (tl == "es") tl = tl "-ES"
  3829. else if (tl == "fi") tl = tl "-FI"
  3830. else if (tl == "fr") tl = tl "-FR"
  3831. else if (tl == "it") tl = tl "-IT"
  3832. else if (tl == "ja") tl = tl "-JP"
  3833. else if (tl == "ko") tl = tl "-KR"
  3834. else if (tl == "nl") tl = tl "-NL"
  3835. else if (tl == "nb") tl = tl "-NO"
  3836. else if (tl == "pl") tl = tl "-PL"
  3837. else if (tl == "pt") tl = tl "-PT"
  3838. else if (tl == "ru") tl = tl "-RU"
  3839. else if (tl == "sv") tl = tl "-SE"
  3840. else if (tl == "yue") ;
  3841. else if (tl == "zh") tl = tl "-CN"
  3842. header = "GET " "/tspeak?"\
  3843. "&language=" tl "&text=" preprocess(text)\
  3844. "&options=" gender "&format=audio%2Fmp3" " HTTP/1.1\r\n"\
  3845. "Host: " HttpHost "\r\n"\
  3846. "Connection: close\r\n"
  3847. if (Option["user-agent"])
  3848. header = header "User-Agent: " Option["user-agent"] "\r\n"
  3849. if (Cookie)
  3850. header = header "Cookie: " Cookie "\r\n"
  3851. content = NULLSTR; isBody = 0
  3852. print header |& HttpService
  3853. while ((HttpService |& getline) > 0) {
  3854. if (isBody)
  3855. content = content ? content "\n" $0 : $0
  3856. else if (length($0) <= 1)
  3857. isBody = 1
  3858. }
  3859. close(HttpService)
  3860. if (!TempFile)
  3861. TempFile = getOutput("mktemp")
  3862. printf("%s", content) > TempFile
  3863. close(TempFile)
  3864. return TempFile
  3865. }
  3866. function bingWebTranslateUrl(uri, sl, tl, hl, _sl, _tl) {
  3867. _sl = sl; _tl = tl
  3868. if (_sl == "bs") _sl = "bs-Latn"
  3869. if (_sl == "zh") _sl = "zh-CHS"
  3870. if (_sl == "zh-CN") _sl = "zh-CHS"
  3871. if (_sl == "zh-TW") _sl = "zh-CHT"
  3872. if (_tl == "bs") _tl = "bs-Latn"
  3873. if (_tl == "zh") _tl = "zh-CHS"
  3874. if (_tl == "zh-CN") _tl = "zh-CHS"
  3875. if (_tl == "zh-TW") _tl = "zh-CHT"
  3876. return "https://www.translatetheweb.com/?" "from=" _sl "&to=" _tl "&a=" uri
  3877. }
  3878. function bingRequestUrl(text, sl, tl, hl) {
  3879. return HttpPathPrefix "/translator/api/Dictionary/Lookup?"\
  3880. "from=" sl "&to=" tl "&text=" preprocess(text)
  3881. }
  3882. function bingPostRequestUrl(text, sl, tl, hl, type) {
  3883. if (type == "lookup")
  3884. return HttpPathPrefix "/tlookupv3"
  3885. else # type == "translate"
  3886. return HttpPathPrefix "/ttranslatev3"
  3887. }
  3888. function bingPostRequestContentType(text, sl, tl, hl, type) {
  3889. return "application/x-www-form-urlencoded"
  3890. }
  3891. function bingPostRequestUserAgent(text, sl, tl, hl, type) {
  3892. return ""
  3893. }
  3894. function bingPostRequestBody(text, sl, tl, hl, type) {
  3895. if (type == "lookup")
  3896. return "&text=" quote(text) "&from=" sl "&to=" tl
  3897. else # type == "translate"
  3898. return "&text=" quote(text) "&fromLang=" sl "&to=" tl
  3899. }
  3900. function bingTranslate(text, sl, tl, hl,
  3901. isVerbose, toSpeech, returnPlaylist, returnIl,
  3902. r,
  3903. content, tokens, ast, dicContent, dicTokens, dicAst,
  3904. _sl, _tl, _hl, il, isPhonetic,
  3905. translation, phonetics, oPhonetics,
  3906. wordClasses, words, wordBackTranslations,
  3907. wShowOriginal, wShowOriginalPhonetics,
  3908. wShowTranslation, wShowTranslationPhonetics,
  3909. wShowLanguages, wShowDictionary,
  3910. i, j, k, group, temp, saveSortedIn) {
  3911. isPhonetic = match(tl, /^@/)
  3912. tl = substr(tl, 1 + isPhonetic)
  3913. if (!getCode(tl)) {
  3914. w("[WARNING] Unknown target language code: " tl)
  3915. } else if (isRTL(tl)) {
  3916. if (!FriBidi)
  3917. w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
  3918. }
  3919. _sl = getCode(sl); if (!_sl) _sl = sl
  3920. _tl = getCode(tl); if (!_tl) _tl = tl
  3921. _hl = getCode(hl); if (!_hl) _hl = hl
  3922. if (_sl == "auto") _sl = "auto-detect"
  3923. if (_sl == "bs") _sl = "bs-Latn"
  3924. if (_sl == "no") _sl = "nb"
  3925. if (_sl == "pt") _sl = "pt-pt"
  3926. if (_sl == "zh-CN") _sl = "zh-Hans"
  3927. if (_sl == "zh-TW") _sl = "zh-Hant"
  3928. if (_tl == "bs") _tl = "bs-Latn"
  3929. if (_tl == "no") _tl = "nb"
  3930. if (_tl == "pt") _tl = "pt-pt"
  3931. if (_tl == "zh-CN") _tl = "zh-Hans"
  3932. if (_tl == "zh-TW") _tl = "zh-Hant"
  3933. content = postResponse(text, _sl, _tl, _hl, "translate")
  3934. if (content == "") {
  3935. HttpHost = "cn.bing.com"
  3936. if (Option["proxy"]) {
  3937. HttpPathPrefix = HttpProtocol HttpHost
  3938. } else {
  3939. HttpService = "/" "inet" "/tcp/0/" HttpHost "/" HttpPort
  3940. }
  3941. content = postResponse(text, _sl, _tl, _hl, "translate")
  3942. }
  3943. if (Option["dump"])
  3944. return content
  3945. tokenize(tokens, content)
  3946. parseJson(ast, tokens)
  3947. l(content, "content", 1, 1)
  3948. l(tokens, "tokens", 1, 0, 1)
  3949. l(ast, "ast")
  3950. if (!isarray(ast) || !anything(ast)) {
  3951. e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
  3952. ExitCode = 1
  3953. return
  3954. }
  3955. translation = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0 SUBSEP "text"])
  3956. returnIl[0] = il = _sl == "auto-detect" ?
  3957. unparameterize(ast[0 SUBSEP 0 SUBSEP "detectedLanguage" SUBSEP "language"]) : _sl
  3958. if (Option["verbose"] < -1)
  3959. return il
  3960. if (Option["verbose"] < 0)
  3961. return getList(il)
  3962. wShowTranslationPhonetics = Option["show-translation-phonetics"]
  3963. if (wShowTranslationPhonetics) {
  3964. split(_tl, group, "-")
  3965. phonetics = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0 SUBSEP "transliteration"\
  3966. SUBSEP "text"])
  3967. if (phonetics == translation) phonetics = ""
  3968. }
  3969. if (!isVerbose) {
  3970. r = isPhonetic && phonetics ?
  3971. prettify("brief-translation-phonetics", join(phonetics, " ")) :
  3972. prettify("brief-translation", s(translation, tl))
  3973. } else {
  3974. wShowOriginal = Option["show-original"]
  3975. wShowTranslation = Option["show-translation"]
  3976. wShowLanguages = Option["show-languages"]
  3977. wShowDictionary = Option["show-dictionary"]
  3978. wShowOriginalPhonetics = Option["show-original-phonetics"]
  3979. if (wShowOriginalPhonetics) {
  3980. split(_sl, group, "-")
  3981. delete ast
  3982. content = postResponse(text, il, il, _hl, "translate")
  3983. tokenize(tokens, content)
  3984. parseJson(ast, tokens)
  3985. oPhonetics = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0\
  3986. SUBSEP "transliteration" SUBSEP "text"])
  3987. if (oPhonetics == text) oPhonetics = ""
  3988. }
  3989. if (!oPhonetics) wShowOriginalPhonetics = 0
  3990. if (!phonetics) wShowTranslationPhonetics = 0
  3991. if (wShowOriginal) {
  3992. if (r) r = r RS RS
  3993. r = r m("-- display original text")
  3994. r = r prettify("original", s(text, _sl))
  3995. if (wShowOriginalPhonetics)
  3996. r = r RS prettify("original-phonetics", showPhonetics(join(oPhonetics, " "), _sl))
  3997. }
  3998. if (wShowTranslation) {
  3999. if (r) r = r RS RS
  4000. r = r m("-- display major translation")
  4001. r = r prettify("translation", s(translation, tl))
  4002. if (wShowTranslationPhonetics)
  4003. r = r RS prettify("translation-phonetics", showPhonetics(join(phonetics, " "), tl))
  4004. }
  4005. if (wShowLanguages) {
  4006. if (r) r = r RS RS
  4007. r = r m("-- display source language -> target language")
  4008. temp = Option["fmt-languages"]
  4009. if (!temp) temp = "[ %s -> %t ]"
  4010. split(temp, group, /(%s|%S|%t|%T)/)
  4011. r = r prettify("languages", group[1])
  4012. if (temp ~ /%s/)
  4013. r = r prettify("languages-sl", getDisplay(il))
  4014. if (temp ~ /%S/)
  4015. r = r prettify("languages-sl", getName(il))
  4016. r = r prettify("languages", group[2])
  4017. if (temp ~ /%t/)
  4018. r = r prettify("languages-tl", getDisplay(tl))
  4019. if (temp ~ /%T/)
  4020. r = r prettify("languages-tl", getName(tl))
  4021. r = r prettify("languages", group[3])
  4022. }
  4023. if (wShowDictionary) {
  4024. dicContent = postResponse(text, il, _tl, _hl, "lookup")
  4025. if (dicContent != "") {
  4026. tokenize(dicTokens, dicContent)
  4027. parseJson(dicAst, dicTokens)
  4028. l(dicContent, "dicContent", 1, 1)
  4029. l(dicTokens, "dicTokens", 1, 0, 1)
  4030. l(dicAst, "dicAst")
  4031. saveSortedIn = PROCINFO["sorted_in"]
  4032. PROCINFO["sorted_in"] = "compareByIndexFields"
  4033. for (i in dicAst) {
  4034. if (match(i, "^0" SUBSEP "0" SUBSEP "translations" SUBSEP "([[:digit:]]+)" SUBSEP\
  4035. "posTag$", group))
  4036. wordClasses[group[1]] = tolower(literal(dicAst[i]))
  4037. }
  4038. for (i in dicAst) {
  4039. if (match(i, "^0" SUBSEP "0" SUBSEP "translations" SUBSEP "([[:digit:]]+)" SUBSEP\
  4040. "displayTarget$", group))
  4041. words[wordClasses[group[1]]][group[1]] = literal(dicAst[i])
  4042. if (match(i, "^0" SUBSEP "0" SUBSEP "translations" SUBSEP "([[:digit:]]+)" SUBSEP\
  4043. "backTranslations" SUBSEP "([[:digit:]]+)" SUBSEP "displayText$", group))
  4044. wordBackTranslations[wordClasses[group[1]]][group[1]][group[2]] = literal(dicAst[i])
  4045. }
  4046. PROCINFO["sorted_in"] = saveSortedIn
  4047. if (r) r = r RS
  4048. r = r m("-- display dictionary entries")
  4049. for (i = 0; i < length(words); i++) {
  4050. r = (i > 0 ? r RS : r) RS prettify("dictionary-word-class", s(wordClasses[i], hl))
  4051. for (j in words[wordClasses[i]]) {
  4052. r = r RS prettify("dictionary-word", ins(1, words[wordClasses[i]][j], tl))
  4053. if (isRTL(il))
  4054. explanation = join(wordBackTranslations[wordClasses[i]][j], ", ")
  4055. else {
  4056. explanation = prettify("dictionary-explanation-item",
  4057. wordBackTranslations[wordClasses[i]][j][0])
  4058. for (k = 1; k < length(wordBackTranslations[wordClasses[i]][j]); k++)
  4059. explanation = explanation prettify("dictionary-explanation", ", ")\
  4060. prettify("dictionary-explanation-item",
  4061. wordBackTranslations[wordClasses[i]][j][k])
  4062. }
  4063. if (isRTL(il))
  4064. r = r RS prettify("dictionary-explanation-item", ins(2, explanation, il))
  4065. else
  4066. r = r RS ins(2, explanation)
  4067. }
  4068. }
  4069. }
  4070. }
  4071. }
  4072. if (toSpeech) {
  4073. returnPlaylist[0]["text"] = translation
  4074. returnPlaylist[0]["tl"] = _tl
  4075. }
  4076. return r
  4077. }
  4078. BEGIN { provides("yandex") }
  4079. function genSID( content, group, temp) {
  4080. content = curl("http://translate.yandex.com")
  4081. match(content, /SID:[[:space:]]*'([^']+)'/, group)
  4082. if (group[1]) {
  4083. split(group[1], temp, ".")
  4084. SID = reverse(temp[1]) "." reverse(temp[2]) "." reverse(temp[3])
  4085. } else {
  4086. e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
  4087. exit 1
  4088. }
  4089. }
  4090. function yandexInit() {
  4091. genSID()
  4092. YandexWebTranslate = "z5h64q92x9.net"
  4093. HttpProtocol = "http://"
  4094. HttpHost = "translate.yandex.net"
  4095. HttpPort = 80
  4096. }
  4097. function yandexRequestUrl(text, sl, tl, hl, group) {
  4098. split(sl, group, "-"); sl = group[1]
  4099. split(tl, group, "-"); tl = group[1]
  4100. return HttpPathPrefix "/api/v1/tr.json/translate?"\
  4101. "id=" SID "-0-0&srv=tr-text"\
  4102. "&text=" preprocess(text) "&lang=" (sl == "auto" ? tl : sl "-" tl)
  4103. }
  4104. function yandexPostRequestBody(text, sl, tl, hl, type) {
  4105. return "text=" quote(text) "&lang=" sl
  4106. }
  4107. function yandexGetDictionaryResponse(text, sl, tl, hl, content, header, isBody, url) {
  4108. split(sl, group, "-"); sl = group[1]
  4109. split(tl, group, "-"); tl = group[1]
  4110. url = "http://dictionary.yandex.net/dicservice.json/lookupMultiple?"\
  4111. "&text=" preprocess(text) "&dict=" sl "-" tl
  4112. content = curl(url)
  4113. return assert(content, "[ERROR] Null response.")
  4114. }
  4115. function yandexTTSUrl(text, tl,
  4116. speaker, emotion, i, group) {
  4117. speaker = NULLSTR
  4118. emotion = NULLSTR
  4119. split(Option["narrator"], group, ",")
  4120. for (i in group) {
  4121. if (group[i] ~ /^(g(ood)?|n(eutral)?|e(vil)?)$/)
  4122. emotion = group[i]
  4123. else if (group[i] ~ /^(f(emale)?|w(oman)?)$/)
  4124. speaker = "alyss"
  4125. else if (group[i] ~ /^m(ale|an)?$/)
  4126. speaker = "zahar"
  4127. else
  4128. speaker = group[i]
  4129. }
  4130. switch (tl) {
  4131. case "ar": tl = "ar_AE"; break
  4132. case "cs": tl = "cs_CZ"; break
  4133. case "da": tl = "da_DK"; break
  4134. case "de": tl = "de_DE"; break
  4135. case "el": tl = "el_GR"; break
  4136. case "en": tl = "en_GB"; break
  4137. case "es": tl = "es_ES"; break
  4138. case "fi": tl = "fi_FI"; break
  4139. case "fr": tl = "fr_FR"; break
  4140. case "it": tl = "it_IT"; break
  4141. case "nl": tl = "nl_NL"; break
  4142. case "no": tl = "no_NO"; break
  4143. case "pl": tl = "pl_PL"; break
  4144. case "pt": tl = "pt_PT"; break
  4145. case "ru": tl = "ru_RU"; break
  4146. case "sv": tl = "sv_SE"; break
  4147. case "tr": tl = "tr_TR"; break
  4148. default: tl = NULLSTR
  4149. }
  4150. return HttpProtocol "tts.voicetech.yandex.net" "/tts?"\
  4151. "text=" preprocess(text) (tl ? "&lang=" tl : tl)\
  4152. (speaker ? "&speaker=" speaker : speaker)\
  4153. (emotion ? "&emotion=" emotion : emotion)\
  4154. "&format=mp3" "&quality=hi"
  4155. }
  4156. function yandexWebTranslateUrl(uri, sl, tl, hl) {
  4157. gsub(/:\/\//, "/", uri)
  4158. return HttpProtocol YandexWebTranslate "/proxy_u/"\
  4159. (sl == "auto" ? tl : sl "-" tl)"/" uri
  4160. }
  4161. function yandexTranslate(text, sl, tl, hl,
  4162. isVerbose, toSpeech, returnPlaylist, returnIl,
  4163. r,
  4164. content, tokens, ast,
  4165. _sl, _tl, _hl, il, isPhonetic,
  4166. translation,
  4167. wShowOriginal, wShowTranslation, wShowLanguages,
  4168. wShowDictionary, dicContent, dicTokens, dicAst,
  4169. i, syn, mean,
  4170. group, temp) {
  4171. isPhonetic = match(tl, /^@/)
  4172. tl = substr(tl, 1 + isPhonetic)
  4173. if (!getCode(tl)) {
  4174. w("[WARNING] Unknown target language code: " tl)
  4175. } else if (isRTL(tl)) {
  4176. if (!FriBidi)
  4177. w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
  4178. }
  4179. _sl = getCode(sl); if (!_sl) _sl = sl
  4180. _tl = getCode(tl); if (!_tl) _tl = tl
  4181. _hl = getCode(hl); if (!_hl) _hl = hl
  4182. content = getResponse(text, _sl, _tl, _hl)
  4183. if (Option["dump"])
  4184. return content
  4185. tokenize(tokens, content)
  4186. parseJson(ast, tokens)
  4187. l(content, "content", 1, 1)
  4188. l(tokens, "tokens", 1, 0, 1)
  4189. l(ast, "ast")
  4190. if (!isarray(ast) || !anything(ast)) {
  4191. e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
  4192. ExitCode = 1
  4193. return
  4194. }
  4195. if (ast[0 SUBSEP "code"] != "200") {
  4196. e("[ERROR] " unparameterize(ast[0 SUBSEP "message"]))
  4197. ExitCode = 1
  4198. return
  4199. }
  4200. translation = unparameterize(ast[0 SUBSEP "text" SUBSEP 0])
  4201. wShowTranslationPhonetics = Option["show-translation-phonetics"]
  4202. if (wShowTranslationPhonetics && _tl != "emj") {
  4203. split(_tl, group, "-")
  4204. data = yandexPostRequestBody(translation, group[1], group[1], _hl, "translit")
  4205. content = curlPost("https://translate.yandex.net/translit/translit", data)
  4206. phonetics = (content ~ /not supported$/) ? "" : unparameterize(content)
  4207. }
  4208. split(unparameterize(ast[0 SUBSEP "lang"]), group, "-")
  4209. returnIl[0] = il = group[1]
  4210. if (Option["verbose"] < -1)
  4211. return il
  4212. else if (Option["verbose"] < 0)
  4213. return getList(il)
  4214. if (!isVerbose) {
  4215. r = isPhonetic && phonetics ?
  4216. prettify("brief-translation-phonetics", join(phonetics, " ")) :
  4217. prettify("brief-translation", s(translation, tl))
  4218. } else {
  4219. wShowOriginal = Option["show-original"]
  4220. wShowTranslation = Option["show-translation"]
  4221. wShowLanguages = Option["show-languages"]
  4222. wShowDictionary = Option["show-dictionary"]
  4223. wShowOriginalPhonetics = Option["show-original-phonetics"]
  4224. if (wShowTranslationPhonetics && il != "emj") {
  4225. split(il, group, "-")
  4226. data = yandexPostRequestBody(text, group[1], group[1], _hl, "translit")
  4227. content = curlPost("https://translate.yandex.net/translit/translit", data)
  4228. oPhonetics = (content ~ /not supported$/) ? "" : unparameterize(content)
  4229. }
  4230. if (!oPhonetics) wShowOriginalPhonetics = 0
  4231. if (!phonetics) wShowTranslationPhonetics = 0
  4232. if (wShowOriginal) {
  4233. if (r) r = r RS RS
  4234. r = r m("-- display original text & phonetics")
  4235. r = r prettify("original", s(text, il))
  4236. if (wShowOriginalPhonetics)
  4237. r = r RS prettify("original-phonetics", showPhonetics(join(oPhonetics, " "), il))
  4238. }
  4239. if (wShowTranslation) {
  4240. if (r) r = r RS RS
  4241. r = r m("-- display major translation")
  4242. r = r prettify("translation", s(translation, tl))
  4243. if (wShowTranslationPhonetics)
  4244. r = r RS prettify("translation-phonetics", showPhonetics(join(phonetics, " "), tl))
  4245. }
  4246. if (wShowLanguages) {
  4247. if (r) r = r RS RS
  4248. r = r m("-- display source language -> target language")
  4249. temp = Option["fmt-languages"]
  4250. if (!temp) temp = "[ %s -> %t ]"
  4251. split(temp, group, /(%s|%S|%t|%T)/)
  4252. r = r prettify("languages", group[1])
  4253. if (temp ~ /%s/)
  4254. r = r prettify("languages-sl", getDisplay(il))
  4255. if (temp ~ /%S/)
  4256. r = r prettify("languages-sl", getName(il))
  4257. r = r prettify("languages", group[2])
  4258. if (temp ~ /%t/)
  4259. r = r prettify("languages-tl", getDisplay(tl))
  4260. if (temp ~ /%T/)
  4261. r = r prettify("languages-tl", getName(tl))
  4262. r = r prettify("languages", group[3])
  4263. }
  4264. if (wShowDictionary && false) {
  4265. dicContent = yandexGetDictionaryResponse(text, il, _tl, _hl)
  4266. tokenize(dicTokens, dicContent)
  4267. parseJson(dicAst, dicTokens)
  4268. if (anything(dicAst)) {
  4269. if (r) r = r RS
  4270. r = r m("-- display dictionary entries")
  4271. saveSortedIn = PROCINFO["sorted_in"]
  4272. PROCINFO["sorted_in"] = "@ind_num_asc"
  4273. for (i in dicAst) {
  4274. if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP\
  4275. "pos$") {
  4276. r = r RS prettify("dictionary-word-class", s((literal(dicAst[i])), hl))
  4277. syn = mean = ""
  4278. }
  4279. if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP\
  4280. "tr" SUBSEP "[[:digit:]]+" SUBSEP\
  4281. "mean" SUBSEP "[[:digit:]]+" SUBSEP "text") {
  4282. if (mean) {
  4283. mean = mean prettify("dictionary-explanation", ", ")\
  4284. prettify("dictionary-explanation-item", s((literal(dicAst[i])), sl))
  4285. } else {
  4286. mean = prettify("dictionary-explanation-item", s((literal(dicAst[i])), sl))
  4287. }
  4288. }
  4289. if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP\
  4290. "tr" SUBSEP "[[:digit:]]+" SUBSEP\
  4291. "syn" SUBSEP "[[:digit:]]+" SUBSEP "text") {
  4292. if (syn) {
  4293. syn = syn prettify("dictionary-explanation", ", ")\
  4294. prettify("dictionary-word", s((literal(dicAst[i])), il))
  4295. } else {
  4296. syn = prettify("dictionary-word", s((literal(dicAst[i])), il))
  4297. }
  4298. }
  4299. if (i ~ "^0" SUBSEP "def" SUBSEP "[[:digit:]]+" SUBSEP\
  4300. "tr" SUBSEP "[[:digit:]]+" SUBSEP "text$") {
  4301. text = prettify("dictionary-word", s((literal(dicAst[i])), il))
  4302. if (syn) {
  4303. r = r RS ins(1, text prettify("dictionary-explanation", ", ") syn)
  4304. } else {
  4305. r = r RS ins(1, text)
  4306. }
  4307. r = r RS ins(2, mean)
  4308. syn = mean = ""
  4309. }
  4310. }
  4311. PROCINFO["sorted_in"] = saveSortedIn
  4312. }
  4313. }
  4314. }
  4315. if (toSpeech) {
  4316. returnPlaylist[0]["text"] = translation
  4317. returnPlaylist[0]["tl"] = _tl
  4318. }
  4319. return r
  4320. }
  4321. BEGIN { provides("apertium") }
  4322. function apertiumInit() {
  4323. HttpProtocol = "http://"
  4324. HttpHost = "www.apertium.org"
  4325. HttpPort = 80
  4326. }
  4327. function apertiumRequestUrl(text, sl, tl, hl) {
  4328. return HttpPathPrefix "/apy/translate?"\
  4329. "langpair=" preprocess(sl) "|" preprocess(tl)\
  4330. "&q=" preprocess(text)
  4331. }
  4332. function apertiumTTSUrl(text, tl, narrator) {
  4333. }
  4334. function apertiumWebTranslateUrl(uri, sl, tl, hl) {
  4335. }
  4336. function apertiumTranslate(text, sl, tl, hl,
  4337. isVerbose, toSpeech, returnPlaylist, returnIl,
  4338. r,
  4339. content, tokens, ast,
  4340. _sl, _tl, _hl, il,
  4341. translation,
  4342. wShowOriginal, wShowTranslation, wShowLanguages,
  4343. group, temp) {
  4344. if (!getCode(tl)) {
  4345. w("[WARNING] Unknown target language code: " tl)
  4346. } else if (isRTL(tl)) {
  4347. if (!FriBidi)
  4348. w("[WARNING] " getName(tl) " is a right-to-left language, but FriBidi is not found.")
  4349. }
  4350. _sl = getCode(sl); if (!_sl) _sl = sl
  4351. _tl = getCode(tl); if (!_tl) _tl = tl
  4352. _hl = getCode(hl); if (!_hl) _hl = hl
  4353. _sl = "auto" == _sl ? "en" : _sl
  4354. content = getResponse(text, _sl, _tl, _hl)
  4355. if (Option["dump"])
  4356. return content
  4357. tokenize(tokens, content)
  4358. parseJson(ast, tokens)
  4359. l(content, "content", 1, 1)
  4360. l(tokens, "tokens", 1, 0, 1)
  4361. l(ast, "ast")
  4362. if (!isarray(ast) || !anything(ast)) {
  4363. e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
  4364. ExitCode = 1
  4365. return
  4366. }
  4367. translation = uprintf(unquote(unparameterize(ast[0 SUBSEP "responseData" SUBSEP "translatedText"])))
  4368. returnIl[0] = il = _sl
  4369. if (Option["verbose"] < -1)
  4370. return il
  4371. else if (Option["verbose"] < 0)
  4372. return getList(il)
  4373. if (!isVerbose) {
  4374. r = translation
  4375. } else {
  4376. wShowOriginal = Option["show-original"]
  4377. wShowTranslation = Option["show-translation"]
  4378. wShowLanguages = Option["show-languages"]
  4379. if (wShowOriginal) {
  4380. if (r) r = r RS RS
  4381. r = r m("-- display original text")
  4382. r = r prettify("original", s(text, il))
  4383. }
  4384. if (wShowTranslation) {
  4385. if (r) r = r RS RS
  4386. r = r m("-- display major translation")
  4387. r = r prettify("translation", s(translation, tl))
  4388. }
  4389. if (wShowLanguages) {
  4390. if (r) r = r RS RS
  4391. r = r m("-- display source language -> target language")
  4392. temp = Option["fmt-languages"]
  4393. if (!temp) temp = "[ %s -> %t ]"
  4394. split(temp, group, /(%s|%S|%t|%T)/)
  4395. r = r prettify("languages", group[1])
  4396. if (temp ~ /%s/)
  4397. r = r prettify("languages-sl", getDisplay(il))
  4398. if (temp ~ /%S/)
  4399. r = r prettify("languages-sl", getName(il))
  4400. r = r prettify("languages", group[2])
  4401. if (temp ~ /%t/)
  4402. r = r prettify("languages-tl", getDisplay(tl))
  4403. if (temp ~ /%T/)
  4404. r = r prettify("languages-tl", getName(tl))
  4405. r = r prettify("languages", group[3])
  4406. }
  4407. }
  4408. if (toSpeech) {
  4409. returnPlaylist[0]["text"] = translation
  4410. returnPlaylist[0]["tl"] = _tl
  4411. }
  4412. return r
  4413. }
  4414. BEGIN {
  4415. provides("spell")
  4416. provides("aspell")
  4417. provides("hunspell")
  4418. }
  4419. function spellInit() {
  4420. Ispell = detectProgram("aspell", "--version") ? "aspell" :
  4421. (detectProgram("hunspell", "--version") ? "hunspell" : "")
  4422. if (!Ispell) {
  4423. e("[ERROR] Spell checker (aspell or hunspell) not found.")
  4424. exit 1
  4425. }
  4426. }
  4427. function aspellInit() {
  4428. if (!(Ispell = detectProgram("aspell", "--version") ? "aspell" : "")) {
  4429. e("[ERROR] Spell checker (aspell) not found.")
  4430. exit 1
  4431. }
  4432. }
  4433. function hunspellInit() {
  4434. if (!(Ispell = detectProgram("hunspell", "--version") ? "hunspell" : "")) {
  4435. e("[ERROR] Spell checker (hunspell) not found.")
  4436. exit 1
  4437. }
  4438. }
  4439. function spellTranslate(text, sl, tl, hl,
  4440. isVerbose, toSpeech, returnPlaylist, returnIl,
  4441. args, i, j, r, line, group, word, sug) {
  4442. args = " -a" (sl != "auto" ? " -d " sl : "")
  4443. if (system("echo" PIPE Ispell args SUPOUT SUPERR)) {
  4444. e("[ERROR] No dictionary for language: " sl)
  4445. exit 1
  4446. }
  4447. i = 1
  4448. r = ""
  4449. while ((("echo " parameterize(text) PIPE Ispell args SUPERR) |& getline line) > 0) {
  4450. match(line,
  4451. /^& (.*) [[:digit:]]+ [[:digit:]]+: ([^,]+)(, ([^,]+))?(, ([^,]+))?/,
  4452. group)
  4453. if (RSTART) {
  4454. ExitCode = 1
  4455. word = group[1]
  4456. sug = "[" group[2]
  4457. if (group[4]) sug = sug "|" group[4]
  4458. if (group[6]) sug = sug "|" group[6]
  4459. sug = sug "]"
  4460. j = i + index(substr(text, i), word) - 1
  4461. r = r substr(text, i, j - i)
  4462. r = r ansi("bold", ansi("red", word)) ansi("yellow", sug)
  4463. i = j + length(word)
  4464. }
  4465. }
  4466. r = r substr(text, i)
  4467. return r
  4468. }
  4469. function aspellTranslate(text, sl, tl, hl,
  4470. isVerbose, toSpeech, returnPlaylist, returnIl) {
  4471. return spellTranslate(text, sl, tl, hl)
  4472. }
  4473. function hunspellTranslate(text, sl, tl, hl,
  4474. isVerbose, toSpeech, returnPlaylist, returnIl) {
  4475. return spellTranslate(text, sl, tl, hl)
  4476. }
  4477. function spellTTSUrl(text, tl, narrator) {
  4478. e("[ERROR] Spell checker does not support TTS.")
  4479. ExitCode = 1
  4480. return
  4481. }
  4482. function aspellTTSUrl(text, tl, narrator) {
  4483. return spellTTSUrl(text, tl)
  4484. }
  4485. function hunspellTTSUrl(text, tl, narrator) {
  4486. return spellTTSUrl(text, tl)
  4487. }
  4488. function spellWebTranslateUrl(uri, sl, tl, hl) {
  4489. e("[ERROR] Spell checker does not support web translation.")
  4490. ExitCode = 1
  4491. return
  4492. }
  4493. function aspellWebTranslateUrl(uri, sl, tl, hl) {
  4494. return spellWebTranslateUrl(uri, sl, tl, hl)
  4495. }
  4496. function hunspellWebTranslateUrl(uri, sl, tl, hl) {
  4497. return spellWebTranslateUrl(uri, sl, tl, hl)
  4498. }
  4499. function loadOptions(script, i, j, tokens, name, value) {
  4500. tokenize(tokens, script)
  4501. for (i in tokens) {
  4502. if (tokens[i] ~ /^:/) {
  4503. name = substr(tokens[i], 2)
  4504. value = tokens[i + 1]
  4505. if (value ~ /^[+-]?((0|[1-9][0-9]*)|[.][0-9]*|(0|[1-9][0-9]*)[.][0-9]*)([Ee][+-]?[0-9]+)?$/) {
  4506. delete Option[name]
  4507. Option[name] = value
  4508. } else if (value == "false" || value == "true") {
  4509. delete Option[name]
  4510. Option[name] = yn(value)
  4511. } else if (value ~ /^".*"$/) {
  4512. delete Option[name]
  4513. Option[name] = literal(value)
  4514. } else if (value == "[") {
  4515. delete Option[name]
  4516. for (j = 1; tokens[i + j + 1] && tokens[i + j + 1] != "]"; j++) {
  4517. if (tokens[i + j + 1] ~ /^".*"$/)
  4518. Option[name][j] = literal(tokens[i + j + 1])
  4519. else {
  4520. e("[ERROR] Malformed configuration.")
  4521. return
  4522. }
  4523. }
  4524. } else {
  4525. e("[ERROR] Malformed configuration.")
  4526. return
  4527. }
  4528. }
  4529. }
  4530. }
  4531. function upgrade( i, newVersion, registry, tokens) {
  4532. RegistryIndex = "https://raw.githubusercontent.com/soimort/translate-shell/registry/index.trans"
  4533. registry = curl(RegistryIndex)
  4534. if (!registry) {
  4535. e("[ERROR] Failed to check for upgrade.")
  4536. ExitCode = 1
  4537. return
  4538. }
  4539. tokenize(tokens, registry)
  4540. for (i in tokens)
  4541. if (tokens[i] == ":translate-shell")
  4542. newVersion = literal(tokens[i + 1])
  4543. if (newerVersion(newVersion, Version)) {
  4544. w("Current version: \t" Version)
  4545. w("New version available: \t" newVersion)
  4546. w("Download from: \t" "https://www.soimort.org/translate-shell/trans")
  4547. } else {
  4548. w("Current version: \t" Version)
  4549. w("Already up-to-date.")
  4550. }
  4551. }
  4552. function welcome() {
  4553. if (Option["fmt-welcome-message"])
  4554. print prettify("welcome-message", Option["fmt-welcome-message"]) > STDERR
  4555. if (Option["fmt-welcome-submessage"])
  4556. print prettify("welcome-submessage", Option["fmt-welcome-submessage"]) > STDERR
  4557. }
  4558. function prompt( i, p, temp) {
  4559. p = Option["fmt-prompt"]
  4560. if (p ~ /%a/) gsub(/%a/, strftime("%a"), p)
  4561. if (p ~ /%A/) gsub(/%A/, strftime("%A"), p)
  4562. if (p ~ /%b/) gsub(/%b/, strftime("%b"), p)
  4563. if (p ~ /%B/) gsub(/%B/, strftime("%B"), p)
  4564. if (p ~ /%c/) gsub(/%c/, strftime("%c"), p)
  4565. if (p ~ /%C/) gsub(/%C/, strftime("%C"), p)
  4566. if (p ~ /%d/) gsub(/%d/, strftime("%d"), p)
  4567. if (p ~ /%D/) gsub(/%D/, strftime("%D"), p)
  4568. if (p ~ /%e/) gsub(/%e/, strftime("%e"), p)
  4569. if (p ~ /%F/) gsub(/%F/, strftime("%F"), p)
  4570. if (p ~ /%g/) gsub(/%g/, strftime("%g"), p)
  4571. if (p ~ /%G/) gsub(/%G/, strftime("%G"), p)
  4572. if (p ~ /%h/) gsub(/%h/, strftime("%h"), p)
  4573. if (p ~ /%H/) gsub(/%H/, strftime("%H"), p)
  4574. if (p ~ /%I/) gsub(/%I/, strftime("%I"), p)
  4575. if (p ~ /%j/) gsub(/%j/, strftime("%j"), p)
  4576. if (p ~ /%m/) gsub(/%m/, strftime("%m"), p)
  4577. if (p ~ /%M/) gsub(/%M/, strftime("%M"), p)
  4578. if (p ~ /%n/) gsub(/%n/, strftime("%n"), p)
  4579. if (p ~ /%p/) gsub(/%p/, strftime("%p"), p)
  4580. if (p ~ /%r/) gsub(/%r/, strftime("%r"), p)
  4581. if (p ~ /%R/) gsub(/%R/, strftime("%R"), p)
  4582. if (p ~ /%u/) gsub(/%u/, strftime("%u"), p)
  4583. if (p ~ /%U/) gsub(/%U/, strftime("%U"), p)
  4584. if (p ~ /%V/) gsub(/%V/, strftime("%V"), p)
  4585. if (p ~ /%w/) gsub(/%w/, strftime("%w"), p)
  4586. if (p ~ /%W/) gsub(/%W/, strftime("%W"), p)
  4587. if (p ~ /%x/) gsub(/%x/, strftime("%x"), p)
  4588. if (p ~ /%X/) gsub(/%X/, strftime("%X"), p)
  4589. if (p ~ /%y/) gsub(/%y/, strftime("%y"), p)
  4590. if (p ~ /%Y/) gsub(/%Y/, strftime("%Y"), p)
  4591. if (p ~ /%z/) gsub(/%z/, strftime("%z"), p)
  4592. if (p ~ /%Z/) gsub(/%Z/, strftime("%Z"), p)
  4593. if (p ~ /%_/)
  4594. gsub(/%_/, showTranslationsOf(Option["hl"]), p)
  4595. if (p ~ /%l/)
  4596. gsub(/%l/, getDisplay(Option["hl"]), p)
  4597. if (p ~ /%L/)
  4598. gsub(/%L/, getName(Option["hl"]), p)
  4599. if (p ~ /%S/) {
  4600. temp = getName(Option["sls"][1])
  4601. for (i = 2; i <= length(Option["sls"]); i++)
  4602. temp = temp "+" getName(Option["sls"][i])
  4603. gsub(/%S/, temp, p)
  4604. }
  4605. if (p ~ /%t/) {
  4606. temp = getDisplay(Option["tl"][1])
  4607. for (i = 2; i <= length(Option["tl"]); i++)
  4608. temp = temp "+" getDisplay(Option["tl"][i])
  4609. gsub(/%t/, temp, p)
  4610. }
  4611. if (p ~ /%T/) {
  4612. temp = getName(Option["tl"][1])
  4613. for (i = 2; i <= length(Option["tl"]); i++)
  4614. temp = temp "+" getName(Option["tl"][i])
  4615. gsub(/%T/, temp, p)
  4616. }
  4617. if (p ~ /%,/) {
  4618. temp = getDisplay(Option["tl"][1])
  4619. for (i = 2; i <= length(Option["tl"]); i++)
  4620. temp = temp "," getDisplay(Option["tl"][i])
  4621. gsub(/%,/, temp, p)
  4622. }
  4623. if (p ~ /%</) {
  4624. temp = getName(Option["tl"][1])
  4625. for (i = 2; i <= length(Option["tl"]); i++)
  4626. temp = temp "," getName(Option["tl"][i])
  4627. gsub(/%</, temp, p)
  4628. }
  4629. if (p ~ /%\//) {
  4630. temp = getDisplay(Option["tl"][1])
  4631. for (i = 2; i <= length(Option["tl"]); i++)
  4632. temp = temp "/" getDisplay(Option["tl"][i])
  4633. gsub(/%\//, temp, p)
  4634. }
  4635. if (p ~ /%\?/) {
  4636. temp = getName(Option["tl"][1])
  4637. for (i = 2; i <= length(Option["tl"]); i++)
  4638. temp = temp "/" getName(Option["tl"][i])
  4639. gsub(/%\?/, temp, p)
  4640. }
  4641. temp = getDisplay(Option["sls"][1])
  4642. for (i = 2; i <= length(Option["sls"]); i++)
  4643. temp = temp "+" getDisplay(Option["sls"][i])
  4644. printf(prettify("prompt", p), temp) > STDERR
  4645. }
  4646. function repl(line, command, group, name, i, value, words) {
  4647. split(line, words, " ")
  4648. command = words[1]
  4649. if (command ~ /^:(q|quit)$/) {
  4650. exit
  4651. } else if (command ~ /^:set$/) {
  4652. name = words[2]
  4653. value = words[3]
  4654. Option[name] = value
  4655. } else if (command ~ /^:show$/) {
  4656. name = words[2]
  4657. print prettify("welcome-submessage", toString(Option[name], 1, 0, 1))
  4658. } else if (command ~ /^:engine$/) {
  4659. value = words[2]
  4660. Option["engine"] = value
  4661. initHttpService()
  4662. } else {
  4663. match(command, /^[{(\[]?((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)[})\]]?$/, group)
  4664. if (RSTART) {
  4665. if (group[1]) {
  4666. split(group[1], Option["sls"], "+")
  4667. Option["sl"] = Option["sls"][1]
  4668. }
  4669. if (group[7]) split(group[7], Option["tl"], "+")
  4670. line = words[2]
  4671. for (i = 3; i <= length(words); i++)
  4672. line = line " " words[i]
  4673. }
  4674. if (line) {
  4675. translates(line)
  4676. if (Option["verbose"]) printf RS
  4677. }
  4678. }
  4679. prompt()
  4680. }
  4681. function init() {
  4682. initGawk()
  4683. initBiDiTerm()
  4684. initBiDi()
  4685. initLocale()
  4686. initLocaleAlias()
  4687. initUserLang()
  4688. RS = "\n"
  4689. ExitCode = 0
  4690. Option["debug"] = 0
  4691. Option["engine"] = "google"
  4692. Option["verbose"] = 1
  4693. Option["show-original"] = 1
  4694. Option["show-original-phonetics"] = 1
  4695. Option["show-translation"] = 1
  4696. Option["show-translation-phonetics"] = 1
  4697. Option["show-prompt-message"] = 1
  4698. Option["show-languages"] = 1
  4699. Option["show-original-dictionary"] = 0
  4700. Option["show-dictionary"] = 1
  4701. Option["show-alternatives"] = 1
  4702. Option["width"] = ENVIRON["COLUMNS"] ? ENVIRON["COLUMNS"] - 2 : 0
  4703. Option["indent"] = 4
  4704. Option["no-ansi"] = 0
  4705. Option["no-autocorrect"] = 0
  4706. Option["no-bidi"] = 0
  4707. Option["force-bidi"] = 0
  4708. Option["no-warn"] = 0
  4709. Option["theme"] = "default"
  4710. Option["dump"] = 0
  4711. Option["play"] = 0
  4712. Option["narrator"] = "female"
  4713. Option["player"] = ENVIRON["PLAYER"]
  4714. Option["no-translate"] = 0
  4715. Option["download-audio"] = 0
  4716. Option["download-audio-as"] = NULLSTR
  4717. Option["view"] = 0
  4718. Option["pager"] = ENVIRON["PAGER"]
  4719. Option["browser"] = ENVIRON["BROWSER"]
  4720. Option["proxy"] = ENVIRON["HTTP_PROXY"] ? ENVIRON["HTTP_PROXY"] : ENVIRON["http_proxy"]
  4721. Option["user-agent"] = ENVIRON["USER_AGENT"] ? ENVIRON["USER_AGENT"] :
  4722. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) "\
  4723. "AppleWebKit/537.36 (KHTML, like Gecko) "\
  4724. "Chrome/81.0.4044.138 "\
  4725. "Safari/537.36"
  4726. Option["ip-version"] = 0
  4727. Option["no-rlwrap"] = 0
  4728. Option["interactive"] = 0
  4729. Option["emacs"] = 0
  4730. Option["input"] = NULLSTR
  4731. Option["output"] = STDOUT
  4732. Option["hl"] = ENVIRON["HOME_LANG"] ? ENVIRON["HOME_LANG"] : UserLang
  4733. Option["sl"] = ENVIRON["SOURCE_LANG"] ? ENVIRON["SOURCE_LANG"] : "auto"
  4734. Option["sls"][1] = Option["sl"]
  4735. Option["tl"][1] = ENVIRON["TARGET_LANG"] ? ENVIRON["TARGET_LANG"] : UserLang
  4736. Option["join-sentence"] = 0
  4737. }
  4738. function initScript( file, line, script, temp) {
  4739. file = ".trans"
  4740. if (!fileExists(file)) {
  4741. file = ENVIRON["HOME"] "/.translate-shell/init.trans"
  4742. if (!fileExists(file)) {
  4743. file = ENVIRON["XDG_CONFIG_HOME"] "/translate-shell/init.trans"
  4744. if (!fileExists(file)) {
  4745. file = ENVIRON["HOME"] "/.config/translate-shell/init.trans"
  4746. if (!fileExists(file)) {
  4747. file = "/etc/translate-shell"
  4748. if (!fileExists(file)) return
  4749. }
  4750. }
  4751. }
  4752. }
  4753. InitScript = file
  4754. script = NULLSTR
  4755. while (getline line < InitScript)
  4756. script = script "\n" line
  4757. loadOptions(script)
  4758. if (!isarray(Option["tl"])) {
  4759. temp = Option["tl"]
  4760. delete Option["tl"]
  4761. Option["tl"][1] = temp
  4762. }
  4763. }
  4764. function initMisc( command, group, temp) {
  4765. initHttpService()
  4766. if (!Option["width"] && detectProgram("tput", "-V")) {
  4767. command = "tput cols" SUPERR
  4768. command | getline temp
  4769. close(command)
  4770. Option["width"] = temp > 5 ? temp - 2 : 64
  4771. }
  4772. if (Option["no-ansi"])
  4773. delete AnsiCode
  4774. if (Option["no-bidi"] || BiDiTerm == "mlterm")
  4775. BiDi = BiDiNoPad = NULLSTR
  4776. else if (!Option["force-bidi"] && BiDiTerm == "konsole") {
  4777. BiDiNoPad = NULLSTR
  4778. BiDi = "sed \"s/'/\\\\\\'/\" | xargs -0 printf '%%%ss'"
  4779. }
  4780. initLocaleDisplay()
  4781. if (Option["no-warn"])
  4782. STDERR = "/dev/null"
  4783. if (Option["play"]) {
  4784. if (!Option["player"]) {
  4785. initAudioPlayer()
  4786. Option["player"] = AudioPlayer ? AudioPlayer : Option["player"]
  4787. if (!Option["player"])
  4788. initSpeechSynthesizer()
  4789. }
  4790. if (!Option["player"] && !SpeechSynthesizer) {
  4791. w("[WARNING] No available audio player or speech synthesizer.")
  4792. Option["play"] = 0
  4793. }
  4794. }
  4795. if (Option["view"]) {
  4796. if (!Option["pager"]) {
  4797. initPager()
  4798. Option["pager"] = Pager
  4799. }
  4800. if (!Option["pager"]) {
  4801. w("[WARNING] No available terminal pager.")
  4802. Option["view"] = 0
  4803. }
  4804. }
  4805. if (!Option["browser"]) {
  4806. Platform = detectProgram("uname", "-s", 1)
  4807. Option["browser"] = Platform == "Darwin" ? "open" : "xdg-open"
  4808. }
  4809. }
  4810. BEGIN {
  4811. init()
  4812. if (!(belongsTo("-no-init", ARGV) || belongsTo("--no-init", ARGV)))
  4813. initScript()
  4814. pos = 0
  4815. noargc = 0
  4816. while (ARGV[++pos]) {
  4817. match(ARGV[pos], /^--?(V|vers(i(on?)?)?)$/)
  4818. if (RSTART) {
  4819. InfoOnly = "version"
  4820. continue
  4821. }
  4822. match(ARGV[pos], /^--?(H|h(e(lp?)?)?)$/)
  4823. if (RSTART) {
  4824. InfoOnly = "help"
  4825. continue
  4826. }
  4827. match(ARGV[pos], /^--?(M|m(a(n(u(al?)?)?)?)?)$/)
  4828. if (RSTART) {
  4829. InfoOnly = "manual"
  4830. continue
  4831. }
  4832. match(ARGV[pos], /^--?(T|ref(e(r(e(n(ce?)?)?)?)?)?)$/)
  4833. if (RSTART) {
  4834. InfoOnly = "reference"
  4835. continue
  4836. }
  4837. match(ARGV[pos], /^--?r$/)
  4838. if (RSTART) {
  4839. w("[WARNING] Option '-r' has been deprecated since version 0.9.\n"\
  4840. " Use option '-T' or '-reference' instead.")
  4841. exit 1
  4842. }
  4843. match(ARGV[pos], /^--?(R|reference-e(n(g(l(i(sh?)?)?)?)?)?)$/)
  4844. if (RSTART) {
  4845. InfoOnly = "reference-english"
  4846. continue
  4847. }
  4848. match(ARGV[pos], /^--?(L|list)(=(.*)?)?$/, group)
  4849. if (RSTART) {
  4850. InfoOnly = "list"
  4851. if (group[2]) {
  4852. if (group[3]) split(group[3], Option["tl"], "+")
  4853. } else
  4854. split(ARGV[++pos], Option["tl"], "+")
  4855. continue
  4856. }
  4857. match(ARGV[pos], /^--?(S|list-e(n(g(i(n(es?)?)?)?)?)?)$/)
  4858. if (RSTART) {
  4859. InfoOnly = "list-engines"
  4860. continue
  4861. }
  4862. match(ARGV[pos], /^--?(U|upgrade)$/)
  4863. if (RSTART) {
  4864. InfoOnly = "upgrade"
  4865. continue
  4866. }
  4867. match(ARGV[pos], /^--?(N|nothing)$/)
  4868. if (RSTART) {
  4869. InfoOnly = "nothing"
  4870. continue
  4871. }
  4872. match(ARGV[pos], /^--?(e|engine)(=(.*)?)?$/, group)
  4873. if (RSTART) {
  4874. Option["engine"] = group[2] ?
  4875. (group[3] ? group[3] : Option["engine"]) :
  4876. ARGV[++pos]
  4877. continue
  4878. }
  4879. match(ARGV[pos], /^\/(.*)$/, group)
  4880. if (RSTART) {
  4881. Option["engine"] = group[1]
  4882. continue
  4883. }
  4884. match(ARGV[pos], /^--?verbose$/)
  4885. if (RSTART) {
  4886. Option["verbose"] = 1
  4887. continue
  4888. }
  4889. match(ARGV[pos], /^--?b(r(i(ef?)?)?)?$/)
  4890. if (RSTART) {
  4891. Option["verbose"] = 0
  4892. continue
  4893. }
  4894. match(ARGV[pos], /^--?d(i(c(t(i(o(n(a(ry?)?)?)?)?)?)?)?)?$/)
  4895. if (RSTART) {
  4896. Option["show-original-dictionary"] = 1
  4897. Option["show-dictionary"] = 0
  4898. Option["show-alternatives"] = 0
  4899. continue
  4900. }
  4901. match(ARGV[pos], /^--?id(e(n(t(i(fy?)?)?)?)?)?$/)
  4902. if (RSTART) {
  4903. Option["verbose"] = Option["verbose"] - 2
  4904. continue
  4905. }
  4906. match(ARGV[pos], /^--?show-original(=(.*)?)?$/, group)
  4907. if (RSTART) {
  4908. Option["show-original"] = yn(group[1] ? group[2] : ARGV[++pos])
  4909. continue
  4910. }
  4911. match(ARGV[pos], /^--?show-original-phonetics(=(.*)?)?$/, group)
  4912. if (RSTART) {
  4913. Option["show-original-phonetics"] = yn(group[1] ? group[2] : ARGV[++pos])
  4914. continue
  4915. }
  4916. match(ARGV[pos], /^--?show-translation(=(.*)?)?$/, group)
  4917. if (RSTART) {
  4918. Option["show-translation"] = yn(group[1] ? group[2] : ARGV[++pos])
  4919. continue
  4920. }
  4921. match(ARGV[pos], /^--?show-translation-phonetics(=(.*)?)?$/, group)
  4922. if (RSTART) {
  4923. Option["show-translation-phonetics"] = yn(group[1] ? group[2] : ARGV[++pos])
  4924. continue
  4925. }
  4926. match(ARGV[pos], /^--?show-prompt-message(=(.*)?)?$/, group)
  4927. if (RSTART) {
  4928. Option["show-prompt-message"] = yn(group[1] ? group[2] : ARGV[++pos])
  4929. continue
  4930. }
  4931. match(ARGV[pos], /^--?show-languages(=(.*)?)?$/, group)
  4932. if (RSTART) {
  4933. Option["show-languages"] = yn(group[1] ? group[2] : ARGV[++pos])
  4934. continue
  4935. }
  4936. match(ARGV[pos], /^--?show-original-dictionary(=(.*)?)?$/, group)
  4937. if (RSTART) {
  4938. Option["show-original-dictionary"] = yn(group[1] ? group[2] : ARGV[++pos])
  4939. continue
  4940. }
  4941. match(ARGV[pos], /^--?show-dictionary(=(.*)?)?$/, group)
  4942. if (RSTART) {
  4943. Option["show-dictionary"] = yn(group[1] ? group[2] : ARGV[++pos])
  4944. continue
  4945. }
  4946. match(ARGV[pos], /^--?show-alternatives(=(.*)?)?$/, group)
  4947. if (RSTART) {
  4948. Option["show-alternatives"] = yn(group[1] ? group[2] : ARGV[++pos])
  4949. continue
  4950. }
  4951. match(ARGV[pos], /^--?w(i(d(th?)?)?)?(=(.*)?)?$/, group)
  4952. if (RSTART) {
  4953. Option["width"] = group[4] ?
  4954. (group[5] ? group[5] : Option["width"]) :
  4955. ARGV[++pos]
  4956. continue
  4957. }
  4958. match(ARGV[pos], /^--?indent(=(.*)?)?$/, group)
  4959. if (RSTART) {
  4960. Option["indent"] = group[1] ?
  4961. (group[2] ? group[2] : Option["indent"]) :
  4962. ARGV[++pos]
  4963. continue
  4964. }
  4965. match(ARGV[pos], /^--?theme(=(.*)?)?$/, group)
  4966. if (RSTART) {
  4967. Option["theme"] = group[1] ?
  4968. (group[2] ? group[2] : Option["theme"]) :
  4969. ARGV[++pos]
  4970. continue
  4971. }
  4972. match(ARGV[pos], /^--?no-theme$/)
  4973. if (RSTART) {
  4974. Option["theme"] = NULLSTR
  4975. continue
  4976. }
  4977. match(ARGV[pos], /^--?no-ansi$/)
  4978. if (RSTART) {
  4979. Option["no-ansi"] = 1
  4980. continue
  4981. }
  4982. match(ARGV[pos], /^--?no-auto(correct)?$/)
  4983. if (RSTART) {
  4984. Option["no-autocorrect"] = 1
  4985. continue
  4986. }
  4987. match(ARGV[pos], /^--?no-bidi/)
  4988. if (RSTART) {
  4989. Option["no-bidi"] = 1
  4990. continue
  4991. }
  4992. match(ARGV[pos], /^--?bidi/)
  4993. if (RSTART) {
  4994. Option["force-bidi"] = 1
  4995. continue
  4996. }
  4997. match(ARGV[pos], /^--?no-warn/)
  4998. if (RSTART) {
  4999. Option["no-warn"] = 1
  5000. continue
  5001. }
  5002. match(ARGV[pos], /^--?dump/)
  5003. if (RSTART) {
  5004. Option["dump"] = 1
  5005. continue
  5006. }
  5007. match(ARGV[pos], /^--?p(l(ay?)?)?$/)
  5008. if (RSTART) {
  5009. Option["play"] = 1
  5010. continue
  5011. }
  5012. match(ARGV[pos], /^--?sp(e(ak?)?)?$/)
  5013. if (RSTART) {
  5014. Option["play"] = 2
  5015. continue
  5016. }
  5017. match(ARGV[pos], /^--?(n|narrator)(=(.*)?)?$/, group)
  5018. if (RSTART) {
  5019. if (!Option["play"]) Option["play"] = 1
  5020. Option["narrator"] = group[2] ?
  5021. (group[3] ? group[3] : Option["narrator"]) :
  5022. ARGV[++pos]
  5023. continue
  5024. }
  5025. match(ARGV[pos], /^--?player(=(.*)?)?$/, group)
  5026. if (RSTART) {
  5027. if (!Option["play"]) Option["play"] = 1
  5028. Option["player"] = group[1] ?
  5029. (group[2] ? group[2] : Option["player"]) :
  5030. ARGV[++pos]
  5031. continue
  5032. }
  5033. match(ARGV[pos], /^--?no-play$/)
  5034. if (RSTART) {
  5035. Option["play"] = 0
  5036. continue
  5037. }
  5038. match(ARGV[pos], /^--?no-tran(s(l(a(te?)?)?)?)?$/)
  5039. if (RSTART) {
  5040. Option["no-translate"] = 1
  5041. continue
  5042. }
  5043. match(ARGV[pos], /^--?download-a(u(d(io?)?)?)?$/)
  5044. if (RSTART) {
  5045. Option["download-audio"] = 1
  5046. continue
  5047. }
  5048. match(ARGV[pos], /^--?download-audio-as(=(.*)?)?$/, group)
  5049. if (RSTART) {
  5050. if (!Option["download-audio"]) Option["download-audio"] = 1
  5051. Option["download-audio-as"] = group[1] ?
  5052. (group[2] ? group[2] : Option["download-audio-as"]) :
  5053. ARGV[++pos]
  5054. continue
  5055. }
  5056. match(ARGV[pos], /^--?v(i(ew?)?)?$/)
  5057. if (RSTART) {
  5058. Option["view"] = 1
  5059. continue
  5060. }
  5061. match(ARGV[pos], /^--?pager(=(.*)?)?$/, group)
  5062. if (RSTART) {
  5063. Option["view"] = 1
  5064. Option["pager"] = group[1] ?
  5065. (group[2] ? group[2] : Option["pager"]) :
  5066. ARGV[++pos]
  5067. continue
  5068. }
  5069. match(ARGV[pos], /^--?no-(view|pager)$/)
  5070. if (RSTART) {
  5071. Option["view"] = 0
  5072. continue
  5073. }
  5074. match(ARGV[pos], /^--?browser(=(.*)?)?$/, group)
  5075. if (RSTART) {
  5076. Option["browser"] = group[1] ?
  5077. (group[2] ? group[2] : Option["browser"]) :
  5078. ARGV[++pos]
  5079. continue
  5080. }
  5081. match(ARGV[pos], /^--?no-browser$/)
  5082. if (RSTART) {
  5083. Option["browser"] = NONE
  5084. continue
  5085. }
  5086. match(ARGV[pos], /^--?(x|proxy)(=(.*)?)?$/, group)
  5087. if (RSTART) {
  5088. Option["proxy"] = group[2] ?
  5089. (group[3] ? group[3] : Option["proxy"]) :
  5090. ARGV[++pos]
  5091. continue
  5092. }
  5093. match(ARGV[pos], /^--?(u|user-agent)(=(.*)?)?$/, group)
  5094. if (RSTART) {
  5095. Option["user-agent"] = group[2] ?
  5096. (group[3] ? group[3] : Option["user-agent"]) :
  5097. ARGV[++pos]
  5098. continue
  5099. }
  5100. match(ARGV[pos], /^--?(4|ipv4|inet4-only)$/)
  5101. if (RSTART) {
  5102. Option["ip-version"] = 4
  5103. continue
  5104. }
  5105. match(ARGV[pos], /^--?(6|ipv6|inet6-only)$/)
  5106. if (RSTART) {
  5107. Option["ip-version"] = 6
  5108. continue
  5109. }
  5110. match(ARGV[pos], /^--?(I|int(e(r(a(c(t(i(ve?)?)?)?)?)?)?)?|shell)$/)
  5111. if (RSTART) {
  5112. Option["interactive"] = 1
  5113. continue
  5114. }
  5115. match(ARGV[pos], /^--?(E|emacs)$/)
  5116. if (RSTART) {
  5117. Option["emacs"] = 1
  5118. continue
  5119. }
  5120. match(ARGV[pos], /^--?no-rlwrap$/)
  5121. if (RSTART) {
  5122. Option["no-rlwrap"] = 1
  5123. continue
  5124. }
  5125. match(ARGV[pos], /^--?prompt(=(.*)?)?$/, group)
  5126. if (RSTART) {
  5127. w("[ERROR] Option '-prompt' has been deprecated since version 0.9.\n"\
  5128. " Use configuration variable 'fmt-prompt' instead.")
  5129. exit 1
  5130. }
  5131. match(ARGV[pos], /^--?prompt-color(=(.*)?)?$/, group)
  5132. if (RSTART) {
  5133. w("[ERROR] Option '-prompt-color' has been deprecated since version 0.9.\n"\
  5134. " Use configuration variable 'sgr-prompt' instead.")
  5135. exit 1
  5136. }
  5137. match(ARGV[pos], /^--?i(n(p(ut?)?)?)?(=(.*)?)?$/, group)
  5138. if (RSTART) {
  5139. Option["input"] = group[4] ?
  5140. (group[5] ? group[5] : Option["input"]) :
  5141. ARGV[++pos]
  5142. continue
  5143. }
  5144. match(ARGV[pos], /^--?o(u(t(p(ut?)?)?)?)?(=(.*)?)?$/, group)
  5145. if (RSTART) {
  5146. Option["output"] = group[5] ?
  5147. (group[6] ? group[6] : Option["output"]) :
  5148. ARGV[++pos]
  5149. continue
  5150. }
  5151. match(ARGV[pos], /^--?(l(a(ng?)?)?|hl)(=(.*)?)?$/, group)
  5152. if (RSTART) {
  5153. Option["hl"] = group[4] ?
  5154. (group[5] ? group[5] : Option["hl"]) :
  5155. ARGV[++pos]
  5156. continue
  5157. }
  5158. match(ARGV[pos], /^--?(s(o(u(r(ce?)?)?)?|l)?|f|from)(=(.*)?)?$/, group)
  5159. if (RSTART) {
  5160. if (group[6]) {
  5161. if (group[7]) split(group[7], Option["sls"], "+")
  5162. } else
  5163. split(ARGV[++pos], Option["sls"], "+")
  5164. Option["sl"] = Option["sls"][1]
  5165. continue
  5166. }
  5167. match(ARGV[pos], /^--?t(a(r(g(et?)?)?)?|l|o)?(=(.*)?)?$/, group)
  5168. if (RSTART) {
  5169. if (group[5]) {
  5170. if (group[6]) split(group[6], Option["tl"], "+")
  5171. } else
  5172. split(ARGV[++pos], Option["tl"], "+")
  5173. continue
  5174. }
  5175. match(ARGV[pos], /^[{(\[]?((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]][[:alpha:]]?[[:alpha:]]?)?)?)[})\]]?$/, group)
  5176. if (RSTART) {
  5177. if (group[1]) {
  5178. split(group[1], Option["sls"], "+")
  5179. Option["sl"] = Option["sls"][1]
  5180. }
  5181. if (group[7]) split(group[7], Option["tl"], "+")
  5182. continue
  5183. }
  5184. match(ARGV[pos], /^--?j(o(i(n(-(s(e(n(t(e(n(ce?)?)?)?)?)?)?)?)?)?)?)?$/)
  5185. if (RSTART) {
  5186. Option["join-sentence"] = 1
  5187. continue
  5188. }
  5189. match(ARGV[pos], /^--?(D|debug)$/)
  5190. if (RSTART) {
  5191. Option["debug"] = 1
  5192. continue
  5193. }
  5194. match(ARGV[pos], /^--?no-init/)
  5195. if (RSTART) continue
  5196. match(ARGV[pos], /^-(-?no-op)?$/)
  5197. if (RSTART) continue
  5198. match(ARGV[pos], /^--$/)
  5199. if (RSTART) {
  5200. ++pos
  5201. break
  5202. }
  5203. noargv[noargc++] = ARGV[pos]
  5204. }
  5205. if (Option["interactive"] && !Option["no-rlwrap"])
  5206. rlwrapMe()
  5207. else if (Option["emacs"] && !Option["interactive"] && !Option["no-rlwrap"])
  5208. if (emacsMe())
  5209. Option["interactive"] = 1
  5210. initMisc()
  5211. switch (InfoOnly) {
  5212. case "version":
  5213. print getVersion()
  5214. exit ExitCode
  5215. case "help":
  5216. print getHelp()
  5217. exit ExitCode
  5218. case "manual":
  5219. showMan()
  5220. exit ExitCode
  5221. case "reference":
  5222. print getReference("endonym")
  5223. exit ExitCode
  5224. case "reference-english":
  5225. print getReference("name")
  5226. exit ExitCode
  5227. case "list":
  5228. print getList(Option["tl"])
  5229. exit ExitCode
  5230. case "list-engines":
  5231. for (translator in Translator)
  5232. print (Option["engine"] == translator ? "* " : " ") translator
  5233. exit ExitCode
  5234. case "upgrade":
  5235. upgrade()
  5236. exit ExitCode
  5237. case "nothing":
  5238. exit ExitCode
  5239. }
  5240. setTheme()
  5241. if (Option["interactive"])
  5242. welcome()
  5243. if (pos < ARGC)
  5244. for (i = pos; i < ARGC; i++)
  5245. noargv[noargc++] = ARGV[i]
  5246. if (noargc > 1 && Option["join-sentence"]) {
  5247. noargv[0] = join(noargv, " ")
  5248. noargc = 1
  5249. }
  5250. if (noargc) {
  5251. for (i = 0; i < noargc; i++) {
  5252. if (Option["verbose"] && i > pos)
  5253. p(prettify("source-seperator", replicate(Option["chr-source-seperator"], Option["width"])))
  5254. translates(noargv[i], 1)
  5255. }
  5256. } else {
  5257. if (!Option["input"]) Option["input"] = STDIN
  5258. }
  5259. if (Option["input"])
  5260. translateMain()
  5261. exit ExitCode
  5262. }
  5263. EOF
  5264. read -r -d '' TRANS_MANPAGE << 'EOF'
  5265. .\" Automatically generated by Pandoc 2.5
  5266. .\"
  5267. .TH "TRANS" "1" "2020\-05\-11" "0.9.6.12" ""
  5268. .hy
  5269. .SH NAME
  5270. .PP
  5271. trans \- Command\-line translator using Google Translate, Bing
  5272. Translator, Yandex.Translate, etc.
  5273. .SH SYNOPSIS
  5274. .PP
  5275. \f[B]trans\f[R] [\f[I]OPTIONS\f[R]]
  5276. [\f[I]SOURCE\f[R]]:[\f[I]TARGETS\f[R]] [\f[I]TEXT\f[R]]...
  5277. .SH DESCRIPTION
  5278. .PP
  5279. This tool translates text into any language from the command\-line,
  5280. using a translation engine such as Google Translate, Bing Translator and
  5281. Yandex.Translate.
  5282. .PP
  5283. Each argument which is not a valid option is treated as \f[I]TEXT\f[R]
  5284. to be translated.
  5285. .PP
  5286. If neither \f[I]TEXT\f[R] nor the input file is specified by
  5287. command\-line arguments, the program will read and translate from
  5288. standard input.
  5289. .SH OPTIONS
  5290. .SS Information options
  5291. .TP
  5292. .B \f[B]\-V\f[R], \f[B]\-version\f[R]
  5293. Print version and exit.
  5294. .TP
  5295. .B \f[B]\-H\f[R], \f[B]\-help\f[R]
  5296. Print help message and exit.
  5297. \f[B]\-M\f[R], \f[B]\-man\f[R]
  5298. Show man page and exit.
  5299. .TP
  5300. .B \f[B]\-T\f[R], \f[B]\-reference\f[R]
  5301. Print reference table of all supported languages and codes, and exit.
  5302. Names of languages are displayed in their endonyms (language name in the
  5303. language itself).
  5304. .TP
  5305. .B \f[B]\-R\f[R], \f[B]\-reference\-english\f[R]
  5306. Print reference table of all supported languages and codes, and exit.
  5307. Names of languages are displayed in English.
  5308. .TP
  5309. .B \f[B]\-L\f[R] \f[I]CODES\f[R], \f[B]\-list\f[R] \f[I]CODES\f[R]
  5310. Print details of languages and exit.
  5311. When specifying two or more language codes, concatenate them by plus
  5312. sign \[dq]+\[dq].
  5313. .TP
  5314. .B \f[B]\-S\f[R], \f[B]\-list\-engines\f[R]
  5315. List available translation engines and exit.
  5316. .TP
  5317. .B \f[B]\-U\f[R], \f[B]\-upgrade\f[R]
  5318. Check for upgrade of this program.
  5319. .SS Translator options
  5320. .TP
  5321. .B \f[B]\-e\f[R] \f[I]ENGINE\f[R], \f[B]\-engine\f[R] \f[I]ENGINE\f[R]
  5322. Specify the translation engine to use.
  5323. (default: google)
  5324. .SS Display options
  5325. .TP
  5326. .B \f[B]\-verbose\f[R]
  5327. Verbose mode.
  5328. .RS
  5329. .PP
  5330. Show the original text and its most relevant translation, then its
  5331. phonetic notation (if any), then its alternative translations (if any)
  5332. or its definition in the dictionary (if it is a word).
  5333. .PP
  5334. This option is unnecessary in most cases since verbose mode is enabled
  5335. by default.
  5336. .RE
  5337. .TP
  5338. .B \f[B]\-b\f[R], \f[B]\-brief\f[R]
  5339. Brief mode.
  5340. .RS
  5341. .PP
  5342. Show the most relevant translation or its phonetic notation only.
  5343. .RE
  5344. .TP
  5345. .B \f[B]\-d\f[R], \f[B]\-dictionary\f[R]
  5346. Dictionary mode.
  5347. .RS
  5348. .PP
  5349. Show the definition of the original word in the dictionary.
  5350. .RE
  5351. .TP
  5352. .B \f[B]\-identify\f[R]
  5353. Language identification.
  5354. .RS
  5355. .PP
  5356. Show the identified language of the original text.
  5357. .RE
  5358. .TP
  5359. .B \f[B]\-show\-original\f[R] \f[I]Y/n\f[R]
  5360. Show original text or not.
  5361. (default: yes)
  5362. .TP
  5363. .B \f[B]\-show\-original\-phonetics\f[R] \f[I]Y/n\f[R]
  5364. Show phonetic notation of original text or not.
  5365. (default: yes)
  5366. .TP
  5367. .B \f[B]\-show\-translation\f[R] \f[I]Y/n\f[R]
  5368. Show translation or not.
  5369. (default: yes)
  5370. .TP
  5371. .B \f[B]\-show\-translation\-phonetics\f[R] \f[I]Y/n\f[R]
  5372. Show phonetic notation of translation or not.
  5373. (default: yes)
  5374. .TP
  5375. .B \f[B]\-show\-prompt\-message\f[R] \f[I]Y/n\f[R]
  5376. Show prompt message or not.
  5377. (default: yes)
  5378. .TP
  5379. .B \f[B]\-show\-languages\f[R] \f[I]Y/n\f[R]
  5380. Show source and target languages or not.
  5381. (default: yes)
  5382. .TP
  5383. .B \f[B]\-show\-original\-dictionary\f[R] \f[I]y/N\f[R]
  5384. Show dictionary entry of original text or not.
  5385. (default: no)
  5386. .RS
  5387. .PP
  5388. This option is enabled in dictionary mode.
  5389. .RE
  5390. .TP
  5391. .B \f[B]\-show\-dictionary\f[R] \f[I]Y/n\f[R]
  5392. Show dictionary entry of translation or not.
  5393. (default: yes)
  5394. .TP
  5395. .B \f[B]\-show\-alternatives\f[R] \f[I]Y/n\f[R]
  5396. Show alternative translations or not.
  5397. (default: yes)
  5398. .TP
  5399. .B \f[B]\-w\f[R] \f[I]NUM\f[R], \f[B]\-width\f[R] \f[I]NUM\f[R]
  5400. Specify the screen width for padding.
  5401. .RS
  5402. .PP
  5403. This option overrides the setting of environment variable
  5404. $\f[B]COLUMNS\f[R].
  5405. .RE
  5406. .TP
  5407. .B \f[B]\-indent\f[R] \f[I]NUM\f[R]
  5408. Specify the size of indent (number of spaces).
  5409. (default: 4)
  5410. .TP
  5411. .B \f[B]\-theme\f[R] \f[I]FILENAME\f[R]
  5412. Specify the theme to use.
  5413. (default: default)
  5414. .TP
  5415. .B \f[B]\-no\-theme\f[R]
  5416. Do not use any other theme than default.
  5417. .TP
  5418. .B \f[B]\-no\-ansi\f[R]
  5419. Do not use ANSI escape codes.
  5420. .TP
  5421. .B \f[B]\-no\-autocorrect\f[R]
  5422. Do not autocorrect.
  5423. (if defaulted by the translation engine)
  5424. .TP
  5425. .B \f[B]\-no\-bidi\f[R]
  5426. Do not convert bidirectional texts.
  5427. .TP
  5428. .B \f[B]\-bidi\f[R]
  5429. Always convert bidirectional texts.
  5430. .TP
  5431. .B \f[B]\-no\-warn\f[R]
  5432. Do not write warning messages to stderr.
  5433. .TP
  5434. .B \f[B]\-dump\f[R]
  5435. Print raw API response instead.
  5436. .SS Audio options
  5437. .TP
  5438. .B \f[B]\-p\f[R], \f[B]\-play\f[R]
  5439. Listen to the translation.
  5440. .RS
  5441. .PP
  5442. You must have at least one of the supported audio players
  5443. (\f[B]mplayer\f[R], \f[B]mpv\f[R] or \f[B]mpg123\f[R]) installed to
  5444. stream from Google Text\-to\-Speech engine.
  5445. Otherwise, a local speech synthesizer may be used instead (\f[B]say\f[R]
  5446. on macOS, \f[B]espeak\f[R] on Linux or other platforms).
  5447. .RE
  5448. .TP
  5449. .B \f[B]\-speak\f[R]
  5450. Listen to the original text.
  5451. .TP
  5452. .B \f[B]\-n\f[R] \f[I]VOICE\f[R], \f[B]\-narrator\f[R] \f[I]VOICE\f[R]
  5453. Specify the narrator, and listen to the translation.
  5454. .RS
  5455. .PP
  5456. Common values for this option are \f[B]male\f[R] and \f[B]female\f[R].
  5457. .RE
  5458. .TP
  5459. .B \f[B]\-player\f[R] \f[I]PROGRAM\f[R]
  5460. Specify the audio player to use, and listen to the translation.
  5461. .RS
  5462. .PP
  5463. Option \f[B]\-play\f[R] will try to use \f[B]mplayer\f[R], \f[B]mpv\f[R]
  5464. or \f[B]mpg123\f[R] by default, since these players are known to work
  5465. for streaming URLs.
  5466. Not all command\-line audio players can work this way.
  5467. Use this option only when you have your own preference.
  5468. .PP
  5469. This option overrides the setting of environment variable
  5470. $\f[B]PLAYER\f[R].
  5471. .RE
  5472. .TP
  5473. .B \f[B]\-no\-play\f[R]
  5474. Do not listen to the translation.
  5475. .TP
  5476. .B \f[B]\-no\-translate\f[R]
  5477. Do not translate anything when using \-speak.
  5478. .TP
  5479. .B \f[B]\-download\-audio\f[R]
  5480. Download the audio to the current directory.
  5481. .TP
  5482. .B \f[B]\-download\-audio\-as\f[R] \f[I]FILENAME\f[R]
  5483. Download the audio to the specified file.
  5484. .SS Terminal paging and browsing options
  5485. .TP
  5486. .B \f[B]\-v\f[R], \f[B]\-view\f[R]
  5487. View the translation in a terminal pager (\f[B]less\f[R], \f[B]more\f[R]
  5488. or \f[B]most\f[R]).
  5489. .TP
  5490. .B \f[B]\-pager\f[R] \f[I]PROGRAM\f[R]
  5491. Specify the terminal pager to use, and view the translation.
  5492. .RS
  5493. .PP
  5494. This option overrides the setting of environment variable
  5495. $\f[B]PAGER\f[R].
  5496. .RE
  5497. .TP
  5498. .B \f[B]\-no\-view\f[R], \f[B]\-no\-pager\f[R]
  5499. Do not view the translation in a terminal pager.
  5500. .TP
  5501. .B \f[B]\-browser\f[R] \f[I]PROGRAM\f[R]
  5502. Specify the web browser to use.
  5503. .RS
  5504. .PP
  5505. This option overrides the setting of environment variable
  5506. $\f[B]BROWSER\f[R].
  5507. .RE
  5508. .TP
  5509. .B \f[B]\-no\-browser\f[R]
  5510. Do not open the web browser.
  5511. .SS Networking options
  5512. .TP
  5513. .B \f[B]\-x\f[R] \f[I]HOST:PORT\f[R], \f[B]\-proxy\f[R] \f[I]HOST:PORT\f[R]
  5514. Use HTTP proxy on given port.
  5515. .RS
  5516. .PP
  5517. This option overrides the setting of environment variables
  5518. $\f[B]HTTP_PROXY\f[R] and $\f[B]http_proxy\f[R].
  5519. .RE
  5520. .TP
  5521. .B \f[B]\-u\f[R] \f[I]STRING\f[R], \f[B]\-user\-agent\f[R] \f[I]STRING\f[R]
  5522. Specify the User\-Agent to identify as.
  5523. .RS
  5524. .PP
  5525. This option overrides the setting of environment variables
  5526. $\f[B]USER_AGENT\f[R].
  5527. .RE
  5528. .TP
  5529. .B \f[B]\-4\f[R], \f[B]\-ipv4\f[R], \f[B]\-inet4\-only\f[R]
  5530. Connect only to IPv4 addresses.
  5531. .TP
  5532. .B \f[B]\-6\f[R], \f[B]\-ipv6\f[R], \f[B]\-inet6\-only\f[R]
  5533. Connect only to IPv6 addresses.
  5534. .SS Interactive shell options
  5535. .TP
  5536. .B \f[B]\-I\f[R], \f[B]\-interactive\f[R], \f[B]\-shell\f[R]
  5537. Start an interactive shell, invoking \f[B]rlwrap\f[R] whenever possible
  5538. (unless \f[B]\-no\-rlwrap\f[R] is specified).
  5539. .TP
  5540. .B \f[B]\-E\f[R], \f[B]\-emacs\f[R]
  5541. Start the GNU Emacs front\-end for an interactive shell.
  5542. .RS
  5543. .PP
  5544. This option does not need to, and cannot be used along with
  5545. \f[B]\-I\f[R] or \f[B]\-no\-rlwrap\f[R].
  5546. .RE
  5547. .TP
  5548. .B \f[B]\-no\-rlwrap\f[R]
  5549. Do not invoke \f[B]rlwrap\f[R] when starting an interactive shell.
  5550. .RS
  5551. .PP
  5552. This option is useful when your terminal type is not supported by
  5553. \f[B]rlwrap\f[R] (e.g.
  5554. \f[B]emacs\f[R]).
  5555. .RE
  5556. .SS I/O options
  5557. .TP
  5558. .B \f[B]\-i\f[R] \f[I]FILENAME\f[R], \f[B]\-input\f[R] \f[I]FILENAME\f[R]
  5559. Specify the input file.
  5560. .RS
  5561. .PP
  5562. Source text to be translated will be read from the input file, instead
  5563. of standard input.
  5564. .RE
  5565. .TP
  5566. .B \f[B]\-o\f[R] \f[I]FILENAME\f[R], \f[B]\-output\f[R] \f[I]FILENAME\f[R]
  5567. Specify the output file.
  5568. .RS
  5569. .PP
  5570. Translations will be written to the output file, instead of standard
  5571. output.
  5572. .RE
  5573. .SS Language preference options
  5574. .TP
  5575. .B \f[B]\-l\f[R] \f[I]CODE\f[R], \f[B]\-hl\f[R] \f[I]CODE\f[R], \f[B]\-lang\f[R] \f[I]CODE\f[R]
  5576. Specify your home language (the language you would like to see for
  5577. displaying prompt messages in the translation).
  5578. .RS
  5579. .PP
  5580. This option affects only the display in verbose mode (anything other
  5581. than source language and target language will be displayed in your home
  5582. language).
  5583. This option has no effect in brief mode.
  5584. .PP
  5585. This option is optional.
  5586. When its setting is omitted, English will be used.
  5587. .PP
  5588. This option overrides the setting of environment variables
  5589. $\f[B]LC_ALL\f[R], $\f[B]LANG\f[R], and $\f[B]HOME_LANG\f[R].
  5590. .RE
  5591. .TP
  5592. .B \f[B]\-s\f[R] \f[I]CODES\f[R], \f[B]\-sl\f[R] \f[I]CODES\f[R], \f[B]\-source\f[R] \f[I]CODES\f[R], \f[B]\-from\f[R] \f[I]CODES\f[R]
  5593. Specify the source language(s) (the language(s) of original text).
  5594. When specifying two or more language codes, concatenate them by plus
  5595. sign \[dq]+\[dq].
  5596. .RS
  5597. .PP
  5598. This option is optional.
  5599. When its setting is omitted, the language of original text will be
  5600. identified automatically (with a possibility of misidentification).
  5601. .PP
  5602. This option overrides the setting of environment variable
  5603. $\f[B]SOURCE_LANG\f[R].
  5604. .RE
  5605. .TP
  5606. .B \f[B]\-t\f[R] \f[I]CODES\f[R], \f[B]\-tl\f[R] \f[I]CODES\f[R], \f[B]\-target\f[R] \f[I]CODES\f[R], \f[B]\-to\f[R] \f[I]CODES\f[R]
  5607. Specify the target language(s) (the language(s) of translated text).
  5608. When specifying two or more language codes, concatenate them by plus
  5609. sign \[dq]+\[dq].
  5610. .RS
  5611. .PP
  5612. This option is optional.
  5613. When its setting is omitted, everything will be translated into English.
  5614. .PP
  5615. This option overrides the setting of environment variables
  5616. $\f[B]LC_ALL\f[R], $\f[B]LANG\f[R], and $\f[B]TARGET_LANG\f[R].
  5617. .RE
  5618. .TP
  5619. .B [\f[I]SOURCE\f[R]]:[\f[I]TARGETS\f[R]]
  5620. A simpler, alternative way to specify the source language and target
  5621. language(s) is to use a shortcut formatted string:
  5622. .RS
  5623. .IP \[bu] 2
  5624. \f[I]SOURCE\-CODE\f[R]:\f[I]TARGET\-CODE\f[R]
  5625. .IP \[bu] 2
  5626. \f[I]SOURCE\-CODE\f[R]:\f[I]TARGET\-CODE1\f[R]+\f[I]TARGET\-CODE2\f[R]+...
  5627. .IP \[bu] 2
  5628. \f[I]SOURCE\-CODE\f[R]=\f[I]TARGET\-CODE\f[R]
  5629. .IP \[bu] 2
  5630. \f[I]SOURCE\-CODE\f[R]=\f[I]TARGET\-CODE1\f[R]+\f[I]TARGET\-CODE2\f[R]+...
  5631. .PP
  5632. Delimiter \[dq]:\[dq] and \[dq]=\[dq] can be used interchangeably.
  5633. .PP
  5634. Either \f[I]SOURCE\f[R] or \f[I]TARGETS\f[R] may be omitted, but the
  5635. delimiter character must be kept.
  5636. .RE
  5637. .SS Text preprocessing options
  5638. .TP
  5639. .B \f[B]\-j\f[R], \f[B]\-join\-sentence\f[R]
  5640. Treat all arguments as one single sentence.
  5641. .SS Other options
  5642. .TP
  5643. .B \f[B]\-no\-init\f[R]
  5644. Do not load any initialization script.
  5645. .TP
  5646. .B \f[B]\-\-\f[R]
  5647. End\-of\-options.
  5648. .RS
  5649. .PP
  5650. All arguments after this option are treated as \f[I]TEXT\f[R] to be
  5651. translated.
  5652. .RE
  5653. .SH EXIT STATUS
  5654. .TP
  5655. .B \f[B]0\f[R]
  5656. Successful translation.
  5657. .TP
  5658. .B \f[B]1\f[R]
  5659. Error.
  5660. .SH ENVIRONMENT
  5661. .TP
  5662. .B \f[B]PAGER\f[R]
  5663. Equivalent to option setting \f[B]\-pager\f[R].
  5664. .TP
  5665. .B \f[B]BROWSER\f[R]
  5666. Equivalent to option setting \f[B]\-browser\f[R].
  5667. .TP
  5668. .B \f[B]PLAYER\f[R]
  5669. Equivalent to option setting \f[B]\-player\f[R].
  5670. .TP
  5671. .B \f[B]HTTP_PROXY\f[R]
  5672. Equivalent to option setting \f[B]\-proxy\f[R].
  5673. .TP
  5674. .B \f[B]USER_AGENT\f[R]
  5675. Equivalent to option setting \f[B]\-user\-agent\f[R].
  5676. .TP
  5677. .B \f[B]HOME_LANG\f[R]
  5678. Equivalent to option setting \f[B]\-lang\f[R].
  5679. .TP
  5680. .B \f[B]SOURCE_LANG\f[R]
  5681. Equivalent to option setting \f[B]\-source\f[R].
  5682. .TP
  5683. .B \f[B]TARGET_LANG\f[R]
  5684. Equivalent to option setting \f[B]\-target\f[R].
  5685. .SH FILES
  5686. .TP
  5687. .B \f[I]/etc/translate\-shell\f[R]
  5688. Initialization script.
  5689. (system\-wide)
  5690. .TP
  5691. .B \f[I]$HOME/.translate\-shell/init.trans\f[R]
  5692. Initialization script.
  5693. (user\-specific)
  5694. .TP
  5695. .B \f[I]$XDG_CONFIG_HOME/translate\-shell/init.trans\f[R]
  5696. Initialization script.
  5697. (user\-specific)
  5698. .TP
  5699. .B \f[I]./.trans\f[R]
  5700. Initialization script.
  5701. (current directory)
  5702. .SH FURTHER DOCUMENTATION
  5703. .PP
  5704. <https://github.com/soimort/translate-shell/wiki>
  5705. .SH REPORTING BUGS
  5706. .PP
  5707. <https://github.com/soimort/translate-shell/issues>
  5708. .SH AUTHORS
  5709. Mort Yao <soi@mort.ninja>.
  5710. EOF
  5711. export TRANS_MANPAGE
  5712. export TRANS_BUILD=release
  5713. gawk -f <(echo -E "$TRANS_PROGRAM") - "$@"