Re: translating external files type thing

2021-04-13 Thread Terry Reedy

On 4/13/2021 4:53 PM, Avi Gross via Python-list wrote:

https://translate.google.com/?sl=is=en=translate

Or, you could do it the hard way.

Kidding aside, there may be a python module you can hand a file name or
contents to and have it do much of the job using some API that may tap into
the above Google resource.


For one chunk of text under 5000 chars, the website is easiest.


Dan specifically suggested importing googletrans ...


The author reverse engineered the undocumented ticket used by the web 
page.  It will work until Google either bans one's IP address or 
disables googletrans by changing the protocol.  Since Google's paid 
service only charges for chars over 500_000 in a month, Google is likely 
better off leaving the protocol alone and only banning users who would 
actually pay if signed up.




-Original Message-
From: Python-list  On
Behalf Of Quentin Bock
Sent: Tuesday, April 13, 2021 3:16 PM
To: python-list@python.org
Subject: translating external files type thing

okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file to
English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable Thanks
--
https://mail.python.org/mailman/listinfo/python-list




--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


RE: translating external files type thing

2021-04-13 Thread Avi Gross via Python-list
https://translate.google.com/?sl=is=en=translate

Or, you could do it the hard way.

Kidding aside, there may be a python module you can hand a file name or
contents to and have it do much of the job using some API that may tap into
the above Google resource.

Dan specifically suggested importing googletrans ...

-Original Message-
From: Python-list  On
Behalf Of Quentin Bock
Sent: Tuesday, April 13, 2021 3:16 PM
To: python-list@python.org
Subject: translating external files type thing

okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file to
English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable Thanks
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: translating external files type thing

2021-04-13 Thread Dan Stromberg
Hi.

Does this give you any ideas?

#!/usr/bin/env python3

"""Quick translation program - English to Icelandic."""

# import pprint

import googletrans

# pprint.pprint(googletrans.LANGUAGES)

translator = googletrans.Translator()

with open('input-file', 'r') as file_:
english_text = file_.read()

translated = translator.translate(english_text, src='en', dest='is')

with open('output-file', 'w') as file_:
file_.write(translated.text)


My input-file contains:
This is a test of the emergency broadcast system.

I like the music of Björk.

HTH.

On Tue, Apr 13, 2021 at 12:16 PM Quentin Bock  wrote:

> okay, so I'm making a translating program, and I have files set to be
> translated (they're in Icelandic) and I want all of them to be read in
> English but I'm not sure how to open the files and translate them at the
> same time. I'm also not even sure how to translate an external file
> to English from another language.
> I can't show code for this because I don't know if it's possible to do what
> I'm asking.
> Hopefully, this question is understandable
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


translating external files type thing

2021-04-13 Thread Quentin Bock
okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file
to English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list