Open cbc02009 opened 3 years ago
Just pushed a libre_translate branch to my repo which you give you a decent place to start. It doesn't look good though because from https://libretranslate.com
The public API on libretranslate.com should be used for testing, personal or infrequent use.
You can run your own server, but that only works on MacOS or Linux and Textractor can only run on those with Wine. Not sure if a Windows program pinging localhost can reach a local native Linux program through Wine.
Just pushed a libre_translate branch to my repo which you give you a decent place to start. It doesn't look good though because from https://libretranslate.com
The public API on libretranslate.com should be used for testing, personal or infrequent use.
You can run your own server, but that only works on MacOS or Linux and Textractor can only run on those with Wine. Not sure if a Windows program pinging localhost can reach a local native Linux program through Wine.
Sorry for the confusion, I'm self-hosting libretranslate in a VM on my local network and exposing it with nginx so that I can access it on my windows computers using http://192.168.0.35:5010/translate
. I'll take a look at the branch and see if I can figure it out, thanks! I'd love to finally get rid of atlas...
@Artikash I was able to get the new plugin compiled, but it's not sending the request correctly.
I'm getting this error in Textractor:
Error while translating: {"error":"Invalid request: missing q parameter"}
and when I look at the nginx logs, this is what the request looks like:
192.168.0.5 - - [22/Mar/2021:18:37:46 +0000] "POST /translate HTTP/1.1" 400 49 "-" "Mozilla/5.0 Textractor"
When I test the same request using postman i get a successful translation and this response:
192.168.0.5 - - [21/Mar/2021:14:16:58 +0000] "POST /translate?q=%E3%81%AF%E3%81%84&source=ja&target=en HTTP/1.1" 200 25 "-" "PostmanRuntime/7.26.10"
I think it's a simple problem of something not being in quite the right place seeing as it's sending /translate
instead of /translate?q=%E3%81%AF%E3%81%84&source=ja&target=en
but I'm well out of my league here (I write C for embedded devices :/ )
I'd hate to take up more of your time, but if you can help me I'd greatly appreciate it.
I haven't used the httprequest library in C++ before, but I'm guessing that you just need to add the "?" in front of the q? I don't see any issues with the rest of the statement.
e.g. FormatString("?q=%S&source=%S&target=%S", Escape(text), translateFrom.Copy(), translateTo.Copy()),
Not quite, looks like the request should be
if (HttpRequest httpRequest{
L"Mozilla/5.0 Textractor",
L"127.0.0.1",
L"POST",
FormatString(L"/translate?q=%s&source=%s&target=%s", Escape(text), translateFrom.Copy(), translateTo.Copy()),
"",
NULL,
5000,
NULL,
0
})
Not quite, looks like the request should be
if (HttpRequest httpRequest{ L"Mozilla/5.0 Textractor", L"127.0.0.1", L"POST", FormatString(L"/translate?q=%s&source=%s&target=%s", Escape(text), translateFrom.Copy(), translateTo.Copy()), "", NULL, 5000, NULL, 0 })
Not sure why, but I had to add .c_str()
after the FormatString call. After that it works great! Too bad the translation is pretty awful, hopefully as they improve the AI training it will get better.
Only to revamp this to see if it could be developed more because...
You can run your own server, but that only works on MacOS or Linux...
I don't know then, but now It very easy to install your own server on Windows installing it through Python as it states here https://github.com/LibreTranslate/LibreTranslate?tab=readme-ov-file#install-and-run
I have installed it right now in Windows 10 through Python 3.11.6 and hosted in simply hosted in localhost:5000 (as it's by default) when running it.
Is there somewhere some tests extensions dlls or something to look up if something works?
Thanks!
I've been testing out LibreTranslate (https://github.com/uav4geo/LibreTranslate) and it would be really cool to have a Textractor plugin. I'm pretty sure I can use the deepltranslate extension as a template, but I don't know any C++, only C.
If you wouldn't mind telling me what I need to change to make it use this API (https://libretranslate.com/docs/) I would greatly appreciate it.