Jump to content

Simple Google Translate


Velislav
 Share

Recommended Posts

2 hours ago, Deye said:

@Musashi, is it still working for you ?

Yes !

Here the script with a longer text :

#include "Json.au3" ; (by @AspirinJunkie)

Global $sRead1 = 'This text will be translated into another language. ' & _
                 'The Moderation team will do their best to act in fair and reasonable manner. Sanctions will ' & _
                 'only be applied as a last resort and any action taken will be explained in the relevant thread. ' & _
                 'If you feel that you have been unfairly moderated then contact the Moderator concerned - ' & _
                 'using a PM or the "Report" button is preferable to opening a new thread (although new members '  & _
                 'may have to do this). But do be aware that the Moderation team has the final word - the rules ' & _
                 'are set out by the site owner and you are only welcome here if you respect his wishes.'


ConsoleWrite("+ >> ORIGINAL: " & $sRead1 & @CRLF)
ConsoleWrite("+ ------------------------------------------------------------------------------ " & @CRLF)
ConsoleWrite("> >> EN->DE  : " & _GoogleAPITranslate($sRead1, "en", "de") & @CRLF)
ConsoleWrite("> >> EN->FR  : " & _GoogleAPITranslate($sRead1, "en", "fr") & @CRLF)
ConsoleWrite("> >> EN->ES  : " & _GoogleAPITranslate($sRead1, "en", "es") & @CRLF)


; ------------ Function : ---------------
Func _GoogleAPITranslate($sMytext, $sFrom, $sTo)
    Local $sUrl, $oHTTP, $sResponse, $JSONData, $sOutput = "", $aData
    $sUrl  = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & $sFrom & "&tl=" & $sTo & "&dt=t&q=" & $sMytext
    $oHTTP = ObjCreate("Microsoft.XMLHTTP")
    $oHTTP.Open("POST", $sUrl, False)
    $oHTTP.Send()
    $sResponse = $oHTTP.ResponseText
    $JSONData  = _JSON_Parse($sResponse)
    If VarGetType($JSONData) = 'Array' Then
        $aData = $JSONData[0]
        If VarGetType($aData) = 'Array' Then
            For $i = 0 To UBound($aData) -1 Step 1
                $sOutput &= ($aData[$i])[0] ;*** & @CRLF
            Next
        EndIf
    EndIf
    Return $sOutput
EndFunc  ;==>_GoogleAPITranslate

Result :

Spoiler

+ >> ORIGINAL: This text will be translated into another language. The Moderation team will do their best to act in fair and reasonable manner. Sanctions will only be applied as a last resort and any action taken will be explained in the relevant thread. If you feel that you have been unfairly moderated then contact the Moderator concerned - using a PM or the "Report" button is preferable to opening a new thread (although new members may have to do this). But do be aware that the Moderation team has the final word - the rules are set out by the site owner and you are only welcome here if you respect his wishes.
+ ------------------------------------------------------------------------------
> >> EN->DE  : Dieser Text wird in eine andere Sprache übersetzt. Das Moderationsteam wird sein Bestes tun, um fair und angemessen zu handeln. Sanktionen werden nur als letztes Mittel verhängt und alle ergriffenen Maßnahmen werden im entsprechenden Thread erläutert. Wenn Sie das Gefühl haben, dass Sie zu Unrecht moderiert wurden, wenden Sie sich an den betreffenden Moderator – per PN oder über die Schaltfläche „Melden“ ist das Eröffnen eines neuen Threads vorzuziehen (obwohl neue Mitglieder dies möglicherweise tun müssen). Aber seien Sie sich bewusst, dass das Moderationsteam das letzte Wort hat – die Regeln werden vom Websitebesitzer festgelegt und Sie sind hier nur willkommen, wenn Sie seine Wünsche respektieren.
> >> EN->FR  : Ce texte sera traduit dans une autre langue. L'équipe de modération fera de son mieux pour agir de manière juste et raisonnable. Les sanctions ne seront appliquées qu'en dernier recours et toute mesure prise sera expliquée dans le fil de discussion correspondant. Si vous estimez que vous avez été injustement modéré, contactez le modérateur concerné - l'utilisation d'un MP ou du bouton "Signaler" est préférable à l'ouverture d'un nouveau fil (bien que les nouveaux membres puissent être amenés à le faire). Mais sachez que l'équipe de modération a le dernier mot - les règles sont définies par le propriétaire du site et vous n'êtes le bienvenu ici que si vous respectez ses souhaits.
> >> EN->ES  : Este texto será traducido a otro idioma. El equipo de moderación hará todo lo posible para actuar de manera justa y razonable. Las sanciones solo se aplicarán como último recurso y cualquier acción tomada se explicará en el hilo correspondiente. Si cree que ha sido moderado injustamente, comuníquese con el Moderador en cuestión; es preferible usar un PM o el botón "Informar" que abrir un nuevo hilo (aunque es posible que los nuevos miembros tengan que hacerlo). Pero tenga en cuenta que el equipo de moderación tiene la última palabra: las reglas las establece el propietario del sitio y solo es bienvenido si respeta sus deseos.

 

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • 6 months later...

Can this be used to translate an English GUI?

For instance, A Label text such as, GUICtrlCreateLabel('Hello', 350, 175, 145, 18) and a button, and a checkbox and so on?

If so, an example would be appreciated as I am having a hard time wrapping my head around its usage as such.

Edited by Shark007
Link to comment
Share on other sites

On 3/1/2023 at 10:20 AM, musicstashall said:

Friends, how do I get a list of all supported languages from Google in this form:
["ps","Pashto"]
...
Then create a two-dimensional array from this.

@musicstashall

Why do you need the intermediate form ["code", "language"] and the array?  The example script below does happen to create that intermediate form, but it is only generated in an intermediate step while filtering the JSON in order to create a TSV list, which is then used to create the 2D AutoIt array.  As you can see in the image below, part of the example script's jq filter produces your intermediate result.  The only difference between the filter in the image and the filter in the script is the last part, "@tsv", which converts the JSON arrays to a TSV list.

image.png.efb495dfc59a7587f9cb9085fde5c22c.png

Example script below:

Spoiler

The comments in the example below should be sufficient to understand how it got the result.

Example script:

#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d

#include <Constants.au3>
#include <Array.au3>
#include <xml2json\xml2json.au3> ;https://www.autoitscript.com/forum/topic/208932-xml2json-udf-transform-xml-to-json/
#include <jq\jq.au3>             ;https://www.autoitscript.com/forum/files/file/502-jq-udf-a-powerful-flexible-json-processor/

Const $JQ_EXE   = "C:\Utils\jq\jq-win64.exe", _ ;Modify path as needed
      $LANG_URL = "https://cloud.google.com/translate/docs/languages"


example()

Func example()
    Const $JQ_FILTER = _
        '#For each table row'                        & @CRLF & _
        '.tbody.tr[]'                                & @CRLF & _
        ''                                           & @CRLF & _
        '| #Create an array with [code, language]'   & @CRLF & _
        '['                                          & @CRLF & _
        '  #if language has array of codes'          & @CRLF & _
        '  if (.td[1].code | type) == "array" then'  & @CRLF & _
        '    #Get first code'                        & @CRLF & _
        '    .td[1].code[0].text'                    & @CRLF & _
        '  else'                                     & @CRLF & _
        '    #Get code'                              & @CRLF & _
        '    .td[1].code.text'                       & @CRLF & _
        '  end, '                                    & @CRLF & _
        ''                                           & @CRLF & _
        '  #Get language'                            & @CRLF & _
        '  .td[0].td'                                & @CRLF & _
        ']'                                          & @CRLF & _
        ''                                           & @CRLF & _
        '| #Convert arrays into TSV list'            & @CRLF & _
        '@tsv'


    Local $sJson      = "", _
          $sWebpage   = "", _
          $sLangTable = "", _
          $sOutput    = ""

    Local $aResult

    Local $hTimer


    $hTimer = TimerInit() ;Start timer

    ;Get web page (Use whatever method works for you COM, cURL, Inet*, etc.)
    $sWebpage = InetRead($LANG_URL)
    If @error Then Exit MsgBox($MB_ICONERROR, "InetRead Error", "@error = " & @error)
    $sWebpage = BinaryToString($sWebpage, $SB_UTF8)

    ConsoleWrite("Time to get webpage         = " & StringFormat("%.3f seconds", TimerDiff($hTimer) / 1000) & @CRLF)

    $hTimer = TimerInit() ;Reset timer

    ;Extract table body from the webpage
    $aResult = StringRegExp($sWebpage, '(?s)<tbody>.*?</tbody>', $STR_REGEXPARRAYMATCH)
    If @error Then Exit MsgBox($MB_ICONERROR, "StringRegExp Error", "@error = " & @error)
    $sLangTable = $aResult[0]

    ;Convert XML (HTML) table to JSON
    $sJson = _Xml2Json($sLangTable)
    If @error Then Exit MsgBox($MB_ICONERROR, "Error", "xml2json failed with @error = " & @error)

    ;Query JSON for TSV list of languages
    _jqInit($JQ_EXE)
    If @error Then Exit MsgBox($MB_ICONERROR, "_jqInit Error", "@error = " & @error)

    $sOutput = _jqExec($sJson, $JQ_FILTER)
    If @error Then Exit MsgBox($MB_ICONERROR, "_jqExec Error", "@error = " & @error)

    ;Convert TSV list to array
    ReDim $aResult[0][2]
    _ArrayAdd($aResult, $sOutput, 0, @TAB)
    If @error Then Exit MsgBox($MB_ICONERROR, "_ArrayAdd Error", "@error = " & @error)

    ;Display elapsed time
    ConsoleWrite("Time to parse & build array = " & StringFormat("%.3f seconds", TimerDiff($hTimer) / 1000) & @CRLF)

    ;Display array
    _ArrayDisplay($aResult, "Supported Languages", "", 0, Default, "Code|Language")
EndFunc

Console Output:

Time to get webpage         = 0.611 seconds
Time to parse & build array = 0.062 seconds

Array:

image.png.29178dbc5eb97952702604b38eb42403.png

 

 

 

Edited by TheXman
Corrected typos in comments
Link to comment
Share on other sites

On 3/2/2023 at 11:35 PM, TheXman said:

Why do you need the intermediate form ["code", "language"] and the array?

Combobox with images of flags of countries are created in my application. Actually, the language of the source and target is selected in the combobox. Your option is not entirely satisfactory, because the page you are parsing has a limited number of display languages. I need to be able to see the page in different languages, respectively, and have the array in different languages too. Try to extract the necessary data from these pages:

$sUrl  = 'https://translate.google.com/?hl=en'
$sUrl  = 'https://translate.google.com/?hl=ru'

Interested in this line:

Spoiler

 

initAft()</script><script id="_ij" nonce="4yDHP_r0rw-pqOulC-d5Rw">window.IJ_values = ['https:\/\/translate.google.com\/about\/?hl\x3dru', true ,[null,null,"",false,null,null,null,false],'0', true ,'https:\/\/translate.google.com\/', null ,'boq_translate-webserver_20230301.07_p0','translate.google.com', 300.0 , false , 0.0 ,'','4yDHP_r0rw-pqOulC-d5Rw','6qmsELr-WxSax3p_nycqWg','DEFAULT','', 2023.0 ,'https:\/\/translate.google.com\/', null ,[["af","ar","az","be","bg","ca","cs","da","de","en","eo","es","eu","fa","fi","fr","gl","gu","hi","hy","id","is","it","iw","ja","ka","kn","ky","mk","ml","mn","ms","ne","nl","no","pa","pl","pt","ru","sk","sq","sr","sv","sw","te","th","tl","uk","ur","uz","zu"],[["af",[["en"]]],["ar",[["en","fr"]]],["as",[["en"]]],["az",[["en"]]],["be",[["en"]]],["bg",[["en"]]],["bn",[["en"]]],["br",[["en"]]],["bs",[["en"]]],["ca",[["en"]]],["ceb",[["en"]]],["cs",[["de","en"]]],["cy",[["en"]]],["da",[["en"]]],["de",[["cs","en","es","pl","ru","tr"]]],["el",[["en"]]],["en",[["af","ar","as","az","be","bg","bn","br","bs","ca","ceb","cs","cy","da","de","el","es","et","eu","fa","fi","fj","fo","fr","fy","ga","gl","gu","ha","hi","hmn","hr","ht","hu","hy","id","ig","is","it","iw","ja","jw","ka","kk","km","kn","ko","ku","la","lah","lo","lt","lv","mi","mk","ml","mn","mr","ms","mt","my","ne","nl","no","ny","pl","pt","ro","ru","sk","sl","so","sq","sr","su","sv","sw","ta","te","tg","th","tl","tr","uk","ur","uz","vi","yi","yo","zh-CN","zh-TW","zu"]]],["es",[["de","en"]]],["et",[["en"]]],["eu",[["en"]]],["fa",[["en"]]],["fi",[["en"]]],["fj",[["en"]]],["fo",[["en"]]],["fr",[["ar","en","pl","ru"]]],["fy",[["en"]]],["ga",[["en"]]],["gl",[["en"]]],["gu",[["en"]]],["ha",[["en"]]],["hi",[["en"]]],["hmn",[["en"]]],["hr",[["en"]]],["ht",[["en"]]],["hu",[["en"]]],["hy",[["en"]]],["id",[["en"]]],["ig",[["en"]]],["is",[["en"]]],["it",[["en"]]],["iw",[["en","ru"]]],["ja",[["en"]]],["jw",[["en"]]],["ka",[["en"]]],["kk",[["en"]]],["km",[["en"]]],["kn",[["en"]]],["ko",[["en"]]],["ku",[["en"]]],["la",[["en"]]],["lah",[["en"]]],["lo",[["en"]]],["lt",[["en"]]],["lv",[["en"]]],["mi",[["en"]]],["mk",[["en"]]],["ml",[["en"]]],["mn",[["en"]]],["mr",[["en"]]],["ms",[["en"]]],["mt",[["en"]]],["my",[["en"]]],["ne",[["en"]]],["nl",[["en"]]],["no",[["en"]]],["ny",[["en"]]],["pl",[["de","en","fr"]]],["pt",[["en"]]],["ro",[["en"]]],["ru",[["de","en","fr","iw"]]],["sk",[["en"]]],["sl",[["en"]]],["so",[["en"]]],["sq",[["en"]]],["sr",[["en"]]],["su",[["en"]]],["sv",[["en"]]],["sw",[["en"]]],["ta",[["en"]]],["te",[["en"]]],["tg",[["en"]]],["th",[["en"]]],["tl",[["en"]]],["tr",[["de","en"]]],["uk",[["en"]]],["ur",[["en"]]],["uz",[["en"]]],["vi",[["en"]]],["yi",[["en"]]],["yo",[["en"]]],["zh-CN",[["en"]]],["zh-TW",[["en"]]],["zu",[["en"]]]]],'ltr', true , false , true , true , true , false , true , false , true , true , false , true , false , true , false , true ,'application\/pdf, application\/vnd.openxmlformats-officedocument.presentationml.presentation, application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application\/vnd.openxmlformats-officedocument.wordprocessingml.document, .pdf, .pptx, .xlsx, .docx','http:\/\/go\/file-tw-dogfood-bug-desktop', false , true ,'https:\/\/accounts.google.com\/AccountChooser?continue\x3dhttps:\/\/translate.google.com\/?hl%3DRU\x26hl\x3dru','https:\/\/accounts.google.com\/ServiceLogin?hl\x3dru\x26continue\x3dhttps:\/\/translate.google.com\/?hl%3DRU','https:\/\/accounts.google.com\/SignOutOptions?continue\x3dhttps:\/\/translate.google.com\/?hl%3DRU','image\/jpeg, image\/png, .jpeg, .jpg, .png', true , false , false , false , false ,'ru','ru', true ,'ru', 3.0 , 3.0 ,'https:\/\/goto2.corp.google.com\/mdtredirect?data_id_filter\x3dtranslate.google.com\x26system_name\x3dtranslate-webserver',[],'https:\/\/myactivity.google.com\/product\/google_translate?utm_source\x3dtranslate_web', null , 10.0 ,'https:\/\/myaccount.google.com\/privacypolicy?hl\x3dru', false ,["Обратный перевод (Ctrl + Shift + S)"], false , false ,'','https:\/\/myaccount.google.com\/termsofservice?hl\x3dru', 5000.0 , null , false , null ,]; window.IJ_valuesCb && window.IJ_valuesCb();</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:0', hash: '1', data:[null,null,true,null,null,1,null,true,true], sideChannel: {}});</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:6', hash: '2', data:[[["af",200],["ar",200],["bg",200],["bn",200],["bs",200],["ca",200],["cs",200],["da",200],["de",200],["el",200],["en",200],["es",200],["et",200],["fi",200],["fr",200],["gu",200],["hi",200],["hr",200],["hu",200],["id",200],["is",200],["it",200],["iw",200],["ja",200],["jw",200],["km",200],["kn",200],["ko",200],["la",200],["lv",200],["ml",200],["mr",200],["ms",200],["my",200],["ne",200],["nl",200],["no",200],["pl",200],["pt",200],["ro",200],["ru",200],["si",200],["sk",200],["sq",200],["sr",200],["su",200],["sv",200],["sw",200],["ta",200],["te",200],["th",200],["tl",200],["tr",200],["uk",200],["ur",200],["vi",200],["zh",200],["zh-CN",200],["zh-TW",200]]], sideChannel: {}});</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:7', hash: '3', data:[null,[["af",["af-ZA",false]],["am",["am-ET",false]],["ar",["ar-EG",true]],["az",["az-AZ",false]],["bg",["bg-BG",false]],["bn",["bn-BD",true]],["ca",["ca-ES",true]],["cs",["cs-CZ",true]],["da",["da-DK",true]],["de",["de-DE",true]],["el",["el-GR",true]],["en",["en-US",true]],["es",["es-US",true]],["et",["et-EE",false]],["eu",["eu-ES",false]],["fa",["fa-IR",true]],["fi",["fi-FI",true]],["fr",["fr-FR",true]],["gl",["gl-ES",false]],["gu",["gu-IN",true]],["hi",["hi-IN",true]],["hr",["hr-HR",true]],["hu",["hu-HU",true]],["hy",["hy-AM",false]],["id",["id-ID",true]],["is",["is-IS",false]],["it",["it-IT",true]],["iw",["he-IL",true]],["ja",["ja-JP",true]],["jw",["jv-ID",false]],["ka",["ka-GE",false]],["kk",["kk-KZ",false]],["km",["km-KH",false]],["kn",["kn-IN",true]],["ko",["ko-KR",true]],["lo",["lo-LA",false]],["lt",["lt-LT",false]],["lv",["lv-LV",false]],["mk",["mk-MK",false]],["ml",["ml-IN",true]],["mn",["mn-MN",false]],["mr",["mr-IN",true]],["ms",["ms-MY",true]],["my",["my-MM",false]],["ne",["ne-NP",false]],["nl",["nl-NL",true]],["no",["nb-NO",true]],["pa",["pa-Guru-IN",false]],["pl",["pl-PL",true]],["pt",["pt-BR",true]],["ro",["ro-RO",true]],["ru",["ru-RU",true]],["si",["si-LK",false]],["sk",["sk-SK",true]],["sl",["sl-SI",true]],["sq",["sq-AL",false]],["sr",["sr-RS",true]],["su",["su-ID",false]],["sv",["sv-SE",true]],["sw",["sw",false]],["ta",["ta-IN",true]],["te",["te-IN",true]],["th",["th-TH",true]],["tl",["fil-PH",true]],["tr",["tr-TR",true]],["uk",["uk-UA",true]],["ur",["ur-PK",true]],["uz",["uz-UZ",false]],["vi",["vi-VN",true]],["zh-CN",["cmn-Hans-CN",true]],["zh-TW",["cmn-Hant-TW",true]],["zu",["zu-ZA",true]]]], sideChannel: {}});</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:4', hash: '4', data:[[],[]], sideChannel: {}});</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:2', hash: '5', data:[["ru","en","de","es","fr"],["ru","en","uk"]], sideChannel: {}});</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:1', hash: '6', data:["auto","ru"], sideChannel: {}});</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:5', hash: '7', data:[["auto","az","ay","sq","am","en","ar","hy","as","af","bm","eu","be","bn","my","bg","bs","bho","cy","hu","vi","haw","gl","el","ka","gn","gu","da","doi","zu","iw","ig","yi","ilo","id","ga","is","es","it","yo","kk","kn","ca","qu","ky","zh-TW","zh-CN","gom","ko","co","xh","ht","kri","ku","ckb","km","lo","la","lv","ln","lt","lg","lb","mai","mk","mg","ms","ml","dv","mt","mi","mr","mni-Mtei","lus","mn","de","ne","nl","no","or","om","pa","fa","pl","pt","ps","rw","ro","ru","sm","sa","ceb","nso","sr","st","si","sd","sk","sl","so","sw","su","tg","th","ta","tt","te","ti","ts","tr","tk","uz","ug","uk","ur","tl","fi","fr","fy","ha","hi","hmn","hr","ak","ny","cs","sv","sn","gd","ee","eo","et","jw","ja"],["az","ay","sq","am","en","ar","hy","as","af","bm","eu","be","bn","my","bg","bs","bho","cy","hu","vi","haw","gl","el","ka","gn","gu","da","doi","zu","iw","ig","yi","ilo","id","ga","is","es","it","yo","kk","kn","ca","qu","ky","zh-TW","zh-CN","gom","ko","co","xh","ht","kri","ku","ckb","km","lo","la","lv","ln","lt","lg","lb","mai","mk","mg","ms","ml","dv","mt","mi","mr","mni-Mtei","lus","mn","de","ne","nl","no","or","om","pa","fa","pl","pt","ps","rw","ro","ru","sm","sa","ceb","nso","sr","st","si","sd","sk","sl","so","sw","su","tg","th","ta","tt","te","ti","ts","tr","tk","uz","ug","uk","ur","tl","fi","fr","fy","ha","hi","hmn","hr","ak","ny","cs","sv","sn","gd","ee","eo","et","jw","ja"]], sideChannel: {}});</script><script nonce="4yDHP_r0rw-pqOulC-d5Rw">AF_initDataCallback({key: 'ds:3', hash: '8', data:[[["auto","Определить язык"],["az","азербайджанский"],["ay","аймара"],["sq","албанский"],["am","амхарский"],["en","английский"],["ar","арабский"],["hy","армянский"],["as","ассамский"],["af","африкаанс"],["bm","бамбара"],["eu","баскский"],["be","белорусский"],["bn","бенгальский"],["my","бирманский"],["bg","болгарский"],["bs","боснийский"],["bho","бходжпури"],["cy","валлийский"],["hu","венгерский"],["vi","вьетнамский"],["haw","гавайский"],["gl","галисийский"],["el","греческий"],["ka","грузинский"],["gn","гуарани"],["gu","гуджарати"],["da","датский"],["doi","догри"],["zu","зулу"],["iw","иврит"],["ig","игбо"],["yi","идиш"],["ilo","илоканский"],["id","индонезийский"],["ga","ирландский"],["is","исландский"],["es","испанский"],["it","итальянский"],["yo","йоруба"],["kk","казахский"],["kn","каннада"],["ca","каталанский"],["qu","кечуа"],["ky","киргизский"],["zh-TW","китайский (традиционный)"],["zh-CN","китайский (упрощенный)"],["gom","конкани"],["ko","корейский"],["co","корсиканский"],["xh","коса"],["ht","креольский (гаити)"],["kri","крио"],["ku","курдский (курманджи)"],["ckb","курдский (сорани)"],["km","кхмерский"],["lo","лаосский"],["la","латинский"],["lv","латышский"],["ln","лингала"],["lt","литовский"],["lg","луганда"],["lb","люксембургский"],["mai","майтхили"],["mk","македонский"],["mg","малагасийский"],["ms","малайский"],["ml","малаялам"],["dv","мальдивский"],["mt","мальтийский"],["mi","маори"],["mr","маратхи"],["mni-Mtei","мейтейлон (манипури)"],["lus","мизо"],["mn","монгольский"],["de","немецкий"],["ne","непальский"],["nl","нидерландский"],["no","норвежский"],["or","ория"],["om","оромо"],["pa","панджаби"],["fa","персидский"],["pl","польский"],["pt","португальский"],["ps","пушту"],["rw","руанда"],["ro","румынский"],["ru","русский"],["sm","самоанский"],["sa","санскрит"],["ceb","себуанский"],["nso","сепеди"],["sr","сербский"],["st","сесото"],["si","сингальский"],["sd","синдхи"],["sk","словацкий"],["sl","словенский"],["so","сомалийский"],["sw","суахили"],["su","сунданский"],["tg","таджикский"],["th","тайский"],["ta","тамильский"],["tt","татарский"],["te","телугу"],["ti","тигринья"],["ts","тсонга"],["tr","турецкий"],["tk","туркменский"],["uz","узбекский"],["ug","уйгурский"],["uk","украинский"],["ur","урду"],["tl","филиппинский"],["fi","финский"],["fr","французский"],["fy","фризский"],["ha","хауса"],["hi","хинди"],["hmn","хмонг"],["hr","хорватский"],["ak","чви"],["ny","чева"],["cs","чешский"],["sv","шведский"],["sn","шона"],["gd","шотландский (гэльский)"],["ee","эве"],["eo","эсперанто"],["et","эстонский"],["jw","яванский"],["ja","японский"]],[["az","азербайджанский"],["ay","аймара"],["sq","албанский"],["am","амхарский"],["en","английский"],["ar","арабский"],["hy","армянский"],["as","ассамский"],["af","африкаанс"],["bm","бамбара"],["eu","баскский"],["be","белорусский"],["bn","бенгальский"],["my","бирманский"],["bg","болгарский"],["bs","боснийский"],["bho","бходжпури"],["cy","валлийский"],["hu","венгерский"],["vi","вьетнамский"],["haw","гавайский"],["gl","галисийский"],["el","греческий"],["ka","грузинский"],["gn","гуарани"],["gu","гуджарати"],["da","датский"],["doi","догри"],["zu","зулу"],["iw","иврит"],["ig","игбо"],["yi","идиш"],["ilo","илоканский"],["id","индонезийский"],["ga","ирландский"],["is","исландский"],["es","испанский"],["it","итальянский"],["yo","йоруба"],["kk","казахский"],["kn","каннада"],["ca","каталанский"],["qu","кечуа"],["ky","киргизский"],["zh-TW","китайский (традиционный)"],["zh-CN","китайский (упрощенный)"],["gom","конкани"],["ko","корейский"],["co","корсиканский"],["xh","коса"],["ht","креольский (гаити)"],["kri","крио"],["ku","курдский (курманджи)"],["ckb","курдский (сорани)"],["km","кхмерский"],["lo","лаосский"],["la","латинский"],["lv","латышский"],["ln","лингала"],["lt","литовский"],["lg","луганда"],["lb","люксембургский"],["mai","майтхили"],["mk","македонский"],["mg","малагасийский"],["ms","малайский"],["ml","малаялам"],["dv","мальдивский"],["mt","мальтийский"],["mi","маори"],["mr","маратхи"],["mni-Mtei","мейтейлон (манипури)"],["lus","мизо"],["mn","монгольский"],["de","немецкий"],["ne","непальский"],["nl","нидерландский"],["no","норвежский"],["or","ория"],["om","оромо"],["pa","панджаби"],["fa","персидский"],["pl","польский"],["pt","португальский"],["ps","пушту"],["rw","руанда"],["ro","румынский"],["ru","русский"],["sm","самоанский"],["sa","санскрит"],["ceb","себуанский"],["nso","сепеди"],["sr","сербский"],["st","сесото"],["si","сингальский"],["sd","синдхи"],["sk","словацкий"],["sl","словенский"],["so","сомалийский"],["sw","суахили"],["su","сунданский"],["tg","таджикский"],["th","тайский"],["ta","тамильский"],["tt","татарский"],["te","телугу"],["ti","тигринья"],["ts","тсонга"],["tr","турецкий"],["tk","туркменский"],["uz","узбекский"],["ug","уйгурский"],["uk","украинский"],["ur","урду"],["tl","филиппинский"],["fi","финский"],["fr","французский"],["fy","фризский"],["ha","хауса"],["hi","хинди"],["hmn","хмонг"],["hr","хорватский"],["ak","чви"],["ny","чева"],["cs","чешский"],["sv","шведский"],["sn","шона"],["gd","шотландский (гэльский)"],["ee","эве"],["eo","эсперанто"],["et","эстонский"],["jw","яванский"],["ja","японский"]]], sideChannel: {}});</script><script id="wiz_jd" nonce="4yDHP_r0rw-pqOulC-d5Rw">if (window['_wjdc']) {const wjd = {}; window['_wjdc'](wjd); delete window['_wjdc'];}</script><script aria-hidden="true" id="WIZ-footer" nonce="4yDHP_r0rw-pqOulC-d5Rw">window.wiz_progress&&window.wiz_progress(); window.stopScanForCss&&window.stopScanForCss(); ccTick('bl');</script></body></html><script nonce="4yDHP_r0rw-pqOulC-d5Rw">this.gbar_=this.gbar_||{};(function(_){var window=this;

 

Edited by musicstashall
Link to comment
Share on other sites

12 hours ago, musicstashall said:

Your option is not entirely satisfactory

My "example" was completely satisfactory based on the information that you provided.  You did not mention anything about being able to display the result in different languages.  In my opinion, based on your expanded definition, I think it was your initial request which was not entirely satisfactory. :)  In other words, if you want better answers, learn how to ask better questions. ;)

 

12 hours ago, musicstashall said:

$sUrl  = 'https://translate.google.com/?hl=en'
$sUrl  = 'https://translate.google.com/?hl=ru'

Looking at the source of the 2 pages that you provided, I can see that the language-specific information is coming from a single URL, based on the language that is desired.  Those URL's provide the results in JSON. Each result contains the native and local language descriptions.  For example, the Russian URL provided the following native and local language description.  Personally, I think getting the information from the result of calling the URL is a better method than trying to extract the information from the source of an inline script in the HTML.  I have also attached the response from a call to the RU-specific language descriptions so you can see the content that is provided, how it is formatted, and how I used it.

Native language descriptions:

image.thumb.png.ddc8692ad444b12f61ff3e441d804ab9.png

Local (RU) language descriptions:

image.thumb.png.49b7f9d23eeff69d23495531022dc69a.png

With just a few slight modification to my original example, you should be able to get your new, more detailed results.  The only changes are a different URI, extracting and modifying the JSON from that new result, and small changes to the jq filter (as I have alluded to).

My example only shows one of the ways that I might go about trying to get the desired result.  It was not meant to be a complete solution.  It was meant for you to learn from if you choose to use some of the concepts, techniques, and tools that I've shown.

I hope it helps.

ru_uri_response.txt

Edited by TheXman
Corrected references to which results were native and which were local.
Link to comment
Share on other sites

59 minutes ago, TheXman said:

You show me something very beautiful and cool, but you don't give it to me, it's more like banter or mockery. Of course, I thank you for your attempt to teach me something new. But I prefer to study thoroughly, and not so from the top. In this case, I needed a quick result. And I don't think I can use your arsenal. How do you imagine that I would dump this arsenal next to my executable file??

Edited by musicstashall
Link to comment
Share on other sites

Not mockery or banter, just facts.  When you do not clearly state what it is you are looking for, it tends to waste your time and the time of the person trying to help you.

 

On 3/4/2023 at 9:31 AM, musicstashall said:

How do you imagine that I would dump this arsenal next to my executable file??

What arsenal?  The only external tool in my example script is the jq executable, the rest are just UDF's.   You don't even need to use jq to process the JSON, you can use whatever you like.  I only provided concepts and techniques.  How you implement them is totally up to you.  So I'm not sure what you mean.

In case you missed it, I provided a fully working example script.  Did you not see it?  It is under the section that says: "Reveal hidden contents".  It showed, among other things, how to get the information in the images.

 

On 3/4/2023 at 9:31 AM, musicstashall said:

In this case, I needed a quick result.

As it says at the bottom of my About Me, I'm not interested in helping those that are merely looking for solutions & answers.  I'm only interested in helping people that are actively trying to learn.

Edited by TheXman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...