Author Topic: translate text by using deepl online translater  (Read 583 times)

0 Members and 1 Guest are viewing this topic.

CADwiesel

  • Newt
  • Posts: 46
  • Wir machen das Mögliche unmöglich
translate text by using deepl online translater
« on: November 18, 2022, 04:46:17 AM »
Hi Guys,
today i'm hoping to get help of the spetialists here.
My challange is to get the result from the deepL translate API but i couldn't send a valid question string.
I tried these two code snippets
Code: [Select]
[code=cadlisp-7];; Get URL Text  -  Lee Mac
;; Retrieves all text data for the given URL
(defun LM:geturltext ( url / obj rtn )
    (if (setq obj (vlax-create-object "winhttp.winhttprequest.5.1"))
        (progn
            (setq rtn
                (vl-catch-all-apply
                   '(lambda nil
                        (vlax-invoke-method obj 'open "GET" url :vlax-false)
                        (vlax-invoke-method obj 'send)
                        (vlax-get-property  obj 'responsebody)
                    )
                )
            )
            (vlax-release-object obj)
            (if (vl-catch-all-error-p rtn)
                (prompt (vl-catch-all-error-message rtn))
                (vl-list->string
                    (mapcar '(lambda ( x ) (lsh (lsh x 24) -24))
                        (vlax-safearray->list (vlax-variant-value rtn))
                    )
                )
            )
        )
    )
)
Code: [Select]
[code=cadlisp-7];; Get-Http  -  Irneb
(defun Get-Http (URL / util fn f txt)
  (setq util (vla-get-Utility (vla-get-ActiveDocument (vlax-get-acad-object))))
  (if (and (vla-IsURL util URL)
           (not (vl-catch-all-error-p
                  (vl-catch-all-apply 'vla-GetRemoteFile (list util URL 'fn :vlax-true))
                )
           )
           (setq f (open fn "r"))
      )
    (progn
      (while (setq fn (read-line f)) (setq txt (cons (strcat fn "\n") txt)))
      (close f)
      (apply 'strcat (reverse txt))
    )
  )
)

The DeepL rules for API quests looks like that:
curl -X POST 'https://api-free.deepl.com/v2/translate' \
   -H 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
   -d 'text=Hello%2C%20world!' \
   -d 'target_lang=DE'


I tried to generate a string like that to use it with these both functions above:
Code: [Select]
"https://api-free.deepl.com/v2/translate/&Authorization:%2C%20DeepL-Auth-Key%2C%20a63b08eb-xxxxxx-7cd59c2f66d9:fx&text=Hello%2C%20world!&target_lang=DE"
How needs the string to be to get a translated result?

Thanks for spending Time into this!
Gruß
CADwiesel
Besucht uns im CHAT

d2010

  • Bull Frog
  • Posts: 296
Re: translate text by using deepl online translater
« Reply #1 on: November 18, 2022, 06:03:45 AM »
This site "https://api-free.deepl.com/v2...." need more tests.
He cannot display translate  messages even in Firefox.exe or GoogleChrome.exe or InternetExplorer8Win.

\Is not  your fault  & VLISP. because  "https://api-free.deepl.com/  " need  more tests  with many operating-systems (win8, linux , ubuntu. win10, knoppix, android, winxp, ) with "MsEdge, FireFox, opera.exe,AcWeb, Comaxton.exe,)

If he failed inside so many operating systems, then "he=//api-free.deepl.com/"                                   
--is broken. is zerop.
 :woow:
After these tests minim70% succesfully, than You can execute  in VLIDE with VLISP with  "api-free.deepl.com/v2"
 :hahanot:
« Last Edit: November 18, 2022, 06:23:49 AM by d2010 »

VovKa

  • Water Moccasin
  • Posts: 1504
  • Ukraine
Re: translate text by using deepl online translater
« Reply #2 on: November 19, 2022, 04:20:14 PM »
in case you want to translate some autocad texts then you might try this app https://www.theswamp.org/index.php?topic=47908.0