i am facing trouble with translating file from one lang to another. kindly please help me to complete it
|
Python
translate file from one lang to another |
|
I gotchu my dude
PHP Code ![]() Donate: 3ABKRghau93ziRaDfVwiiwtjky3i1gLrKn
Feb 14, 2020 06:31 AM
(This post was last modified: Feb 14, 2020 03:44 PM by Riԁdle.)
Could use https://pythonhosted.org/goslate/ , above post won't work, 1 it doesn't try to extract translated text from the form, 2 the form gets it's text set by javascript, so you'd need to use a browser (like selenium) then extract the text from the form, and 3 there is a limit (2000 I believe) on how many characters you can use in a url so you'd have to chunk the text you want to translate
i like python lua js
(Feb 14, 2020 06:31 AM)Riԁdle Wrote: Could use https://pythonhosted.org/goslate/ , above post won't work, 1 it doesn't try to extract translated text from the form, 2 the form gets it's text set by javascript, so you'd need to use a browser (like selenium) then extract the text from the form, and 3 there is a limit (2000 I believe) on how many characters you can use in a url so you'd have to chunk the text you want to translate Getting this error🤦♂️ translated_line = gs.translate(line) TypeError: translate() missing 1 required positional argument: 'target_language'
Feb 15, 2020 06:14 AM
(This post was last modified: Feb 15, 2020 06:16 AM by Riԁdle.)
The basic usage is simple:
Code >>> import goslateExample code from link above, you forgot the second parameter, which is the target_language, which looks like it takes abbreviated language name as a string
i like python lua js
(Feb 15, 2020 06:14 AM)Riԁdle Wrote: The basic usage is simple: i am getting that but unable to translate whole document at a time🤦♂️...... i am trying whatever i can do i am doing but not able to do on complete document
Feb 15, 2020 12:43 PM
(This post was last modified: Feb 15, 2020 12:48 PM by lockhead.)
(Feb 15, 2020 08:52 AM)Mr.7 Wrote: i am getting that but unable to translate whole document at a time🤦♂️...... i am trying whatever i can do i am doing but not able to do on complete document PHP Code ![]() Donate: 3ABKRghau93ziRaDfVwiiwtjky3i1gLrKn
Feb 16, 2020 12:26 AM
(This post was last modified: Feb 16, 2020 01:21 AM by Mr.7.)
(Feb 15, 2020 12:43 PM)lockhead Wrote: its working but how to write lines in new line..... its wrtting whole document in single line only
My dude do you have any idea what you're doing? You really shouldn't just ask people to do all the work for you if you don't have the slightest clue of what's going on.
PHP Code ![]() Donate: 3ABKRghau93ziRaDfVwiiwtjky3i1gLrKn (Feb 16, 2020 02:38 AM)lockhead Wrote: My dude do you have any idea what you're doing? You really shouldn't just ask people to do all the work for you if you don't have the slightest clue of what's going on. this is code import goslate gs = goslate.Goslate() inputFileName = "data1.txt" lang = "hi" with open(inputFileName, "r" , encoding="utf8") as inputf: outputFileName = f"{inputFileName[-4:]}_translate_{lang}.txt" with open(outputFileName, "w", encoding="UTF-8") as outputf: for line in inputf.readlines(): text = inputf.readlines() line += "\n" outputf.write(gs.translate(line, lang)) getting error like this raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 429: Too Many Requests (Feb 16, 2020 02:44 AM)Mr.7 Wrote: this is code PHP Code ![]() Donate: 3ABKRghau93ziRaDfVwiiwtjky3i1gLrKn |
|
|


![[Image: 0DvFxnA.gif]](https://i.imgur.com/0DvFxnA.gif)