Page 1 of 1

Translator launched from bat-file

Posted: Tue Feb 19, 2019 9:44 am
by Eugene Lutsenko
Does anyone know a file translator run from a bat-file?

It can be a local translator program with its own dictionaries, it can be a program that accesses dictionaries on the Internet. and can be at all site. I know how to do it in Unix (Cygwin). And it is made in the system of Eidos. But Cygwin itself takes up a lot of space (about 300 MB) and Google translator stopped working

Re: Translator launched from bat-file

Posted: Wed Feb 20, 2019 3:36 am
by skiman
Hi,

Google translator didn't stop, but is changed.

You can do it this way if you want. Don't use this too much or Google will block your IP.

Code: Select all

https://translate.googleapis.com/translate_a/single?client=gtx&sl=nl&tl=fr&dt=t&q=dit%20is%20een%20test
sl=nl (Source Language)
tl=fr (To Language)
q=... text to translate

Re: Translator launched from bat-file

Posted: Wed Feb 20, 2019 7:39 pm
by Eugene Lutsenko
Thank you, Chris! It's working!

For example:

Code: Select all

https://translate.googleapis.com/translate_a/single?client=gtx&sl=ru&tl=en&dt=t&q=Привет, Мир!
Writes to the downloads folder file: а.txt this content:

[[["Hello World!","Привет, Мир!",null,null,1]],null,"ru"]

That's right.

With regard to limitations, it seems they are not very strong:

https://cloud.google.com/translate/pricing
https://cloud.google.com/translate/quotas

Chris! And how to set the file translation in this style?

Here found one more variant. Even easier to unpack the result:

Code: Select all

http://translate.google.ru/translate_a/t?client=x&text={Привет, Мир!}&hl=en&sl=ru&tl=en
As a result, the file is written to the download folder: f.txt with such content:
"{Hello World!}"

This raises two questions:
1. How to translate a file, not a string specified directly in the command in the address bar?
2. How to specify the path where to write the output file with the translation result?

And it may be possible to get the result of the translation immediately in the form of a variable value, as in C#:
https://studassistent.ru/charp/zapros-n ... oogle-ru-c

This would be much more convenient than taking the translation result from a file. And from the file, which generally speaking is unknown where

Re: Translator launched from bat-file

Posted: Wed Feb 20, 2019 11:21 pm
by skiman
Hi,

Use loadfromurl, then you get the result in a variable.
cResult := loadfromurl(...)

Re: Translator launched from bat-file

Posted: Thu Feb 21, 2019 11:28 am
by Eugene Lutsenko
you cannot use this feature yet

Re: Translator launched from bat-file

Posted: Fri Feb 22, 2019 10:13 pm
by Eugene Lutsenko
with this command does not work, because there are conflicts in ch-files, etc. And there is no option to appeal to the online translator with the translation of the file?

Re: Translator launched from bat-file

Posted: Sat Feb 23, 2019 8:49 am
by skiman
I'm using the loadfromurl() function of Phil Ide for years. It is working without any problem.

Re: Translator launched from bat-file

Posted: Sat Feb 23, 2019 1:07 pm
by Eugene Lutsenko
String:

Code: Select all

https://translate.googleapis.com/translate_a/single?client=gtx&sl=ru&tl=en&dt=t&q=Привет, Мир!
works correctly from the address bar. But when you access it programmatically and write its output to a file, you get an incomprehensible encoding (Win 65001 (UTF-8) without ROM). This is when translated from Russian into English. Is there a parameter somewhere in this line that specifies the encoding of the input text? In principle, I Russian is not going to translate, so you can use it. Thank you!