Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect with libretranslate, online or local #1

Open
rgaricano opened this issue Jul 15, 2024 · 2 comments
Open

Can't connect with libretranslate, online or local #1

rgaricano opened this issue Jul 15, 2024 · 2 comments
Labels
question Further information is requested

Comments

@rgaricano
Copy link

I tried to connect with local or online libretranslate but allways is empty.
When i do directly on webbroser it work:

curl -X 'POST'
'http://127.0.0.1:5000/translate'
-H 'accept: application/json'
-H 'Content-Type: application/x-www-form-urlencoded'
-d 'q=hola&source=es&target=en&format=text&alternatives=3'

Request URL: http://127.0.0.1:5000/translate

Server response: Code 200
{
"alternatives": [
"hi",
"hello",
"hey"
],
"translatedText": "hello"
}

Response headers

access-control-allow-credentials: true access-control-allow-headers: Authorization,Content-Type access-control-allow-methods: GET,POST access-control-allow-origin: * access-control-expose-headers: Authorization access-control-max-age: 1728000 content-length: 63 content-type: application/json date: Mon,15 Jul 2024 10:07:11 GMT server: waitress


This is what OmegaT log:

31278: Error: org.omegat.util.HttpConnectionUtils$ResponseError: 400: BAD REQUEST
31278: Error: at org.omegat.util.HttpConnectionUtils.getStringContent(HttpConnectionUtils.java:396)
31278: Error: at org.omegat.util.HttpConnectionUtils.getStringContent(HttpConnectionUtils.java:388)
31278: Error: at org.omegat.util.HttpConnectionUtils.post(HttpConnectionUtils.java:324)
31278: Error: at org.omegat.machinetranslators.libretranslate.LibreTranslate.translate(LibreTranslate.java:114)
31278: Error: at org.omegat.core.machinetranslators.BaseCachedTranslate.getTranslation(BaseCachedTranslate.java:118)
31278: Error: at org.omegat.gui.exttrans.MachineTranslateTextArea$FindThread.getTranslation(MachineTranslateTextArea.java:275)
31278: Error: at org.omegat.gui.exttrans.MachineTranslateTextArea$FindThread.search(MachineTranslateTextArea.java:258)
31278: Error: at org.omegat.gui.exttrans.MachineTranslateTextArea$FindThread.search(MachineTranslateTextArea.java:233)
31278: Error: at org.omegat.gui.common.EntryInfoSearchThread.run(EntryInfoSearchThread.java:96)

tested in ubuntu 22.04 & windows 10

@rgaricano
Copy link
Author

I solved it changing http request, removing headers parameter it work, for some reason that function is not working properly:
String v = HttpConnectionUtils.post(serverUrl, params);

Well, I hope work on it for activate API-KEY and alternatives translates.

@brandelune brandelune assigned miurahr and unassigned miurahr Jul 21, 2024
@miurahr miurahr added the question Further information is requested label Jul 23, 2024
@miurahr
Copy link
Member

miurahr commented Jul 23, 2024

As README.md writes:

Not supported yet

API key authentication
HTML format

Authentication is not supported. As usual, you are welcome to join a development and propose an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants