Translate button missing with libretranslate

Dear Discourse Group,
First, to the authors of this project, my profound thanks and
respect. Being a programmer myself I can appreicate the many hours
that have gone into creating this project.

Over the last few days, I have installed discourse at:

and also added the translate plugin. Here is the relevant part of my
app.yml file.

hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- git clone GitHub - discourse/docker_manager: plugin for use with discourse docker image
- git clone GitHub - LibreTranslate/discourse-translator: Discourse translator with LibreTranslate support.

First, the default locale of my discourse instance is set to English
at https://discourse.newcity.mx/admin/site_settings/category/required

When I access the plugin/LibreTranslate tab of my admin screen, I check:
Allow inline translation of posts.
and set translater to LibreTranslate
I am not sure what (if anything) I should put in the
LibreTranslate API Endpoint field.

The plugin tab says that discourse-translator is enabled, the version
is 0.4.0, there is a green checkmark, and a Y under the enabled
column. So far all good, no?

However when I access a page, I don’t see any icon/option to do a
translation. The leftmost icon at the bottom of the message is the
“share a link to the post”.

I did install libretranslate following the instructions at:

GitHub - LibreTranslate/LibreTranslate: Free and Open Source Machine Translation API. 100% self-hosted, offline capable and easy to setup.

which you can verify by going to http://nadineloveshenry.com:5000/

I read:

Where I discovered “The translate button will only show if we detect
that the language of the post is different from the current locale
which that user has selected.”

So I removed English as firefox’s language and changed it to
Espanol(MX), and connected to my site via a VPN through Spain just to
make sure there was not trace of USA left. The request headers that
were sent wre:

GET /t/welcome-to-new-city-discourse/7 HTTP/1.1
Host: discourse.newcity.mx
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8
Accept-Language: es-MX,es;q=0.5
Accept-Encoding: gzip, deflate, br

But still no joy.

Can anyone tell me what I am missing?

On another, and perhaps related note, when I run:

./launcher enter app

The response I get is:

x86_64 arch detected.
OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/1: operation not permitted: unknown

Thanks in advance for your help.
Best wishes,
Henry Laxen

1 Like

my guess would be http://nadineloveshenry.com:5000/translate
as it seems to work:

Thanks Benjamin for the idea, but it doesn’t seen to work. I put
http://nadineloveshenry.com:5000/translate
in the LibreTranslate API Endpoint field,

changed my firefox settings to German:

GET /t/test-libretranslate/17 HTTP/1.1
Host: discourse.newcity.mx
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8
Accept-Language: de

But still no little world button appears. Are there any other ideas out there, or even a pointer as to how I can track this down. Does anyone have a working libretranslate discourse site working? Thanks again Benjamin.

1 Like

ha, my bad, the endpoint should be:
http://nadineloveshenry.com:5000

Still don’t know if and how it works though :sweat_smile:

Hi @henrylaxen. :wave:

I don’t know how to fix your issue, but I wanted to point out were are potentially close to officially supporting LibreTranslate in our plugin, see LibreTranslate provider support by pierotofy · Pull Request #36 · discourse/discourse-translator · GitHub for what needs to be done. :slight_smile:

2 Likes

it seems there is something wrong here:

Should be SUPPORTED_LANG_MAPPING I think (and thereafter)

it also seems that the POST method is not allowed for the /languages url called here:

it needs GET

Dear Benjamin, Maiki & co,
Wow. Thanks so much for digging into this. Benjamin, I tried changing the endpoint to http://nadineloveshenry.com:5000 but it had no effect. After reading the discussion for pull request 36, it sounds like it will be merged imminently, so I would rather wait a few days than try to use your branch at GitHub - LibreTranslate/discourse-translator: Discourse translator with LibreTranslate support., which I am not sure how to do. Please let me know if I can help you guys in any way.

I just noticed a new version is available, 2.9.0.beta5. I upgraded to it, and Now when I have translation enabled, by checking the box labelled

Allow inline translation of posts.

at the https://discourse.newcity.mx/admin/site_settings/category/plugins?filter=plugin%3Adiscourse-translator page,

when I go to Test libretranslate - #2 - New City Tijuana Discourse
or in fact any page, I get an internal server error.


Request:
GET /t/test-libretranslate/17 HTTP/1.1
Host: discourse.newcity.mx
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US
Accept-Encoding: gzip, deflate, br
DNT: 1
Connection: keep-alive
Cookie: _t=7TrnwomqGwDw359BMpi9EJo0cXFEYNpuysEJvGrkYwUG8D5zyJwVWd4iqKPmxUd2UUUG%2BH9hShgBeoCd7U51pJZg6CQYhKABm0AxQg0%2Bdqd9q1ODmRAPKp4INqAZHQuPZxWH9cObvpdaYaQFSbJiWRlfK0rRRgC%2FIqqgafn7w%2FAbTsO3N%2FmVLUIPj0t8PbJWDMYp1dDjevq4lpdNMYSViWbtHrFgXw89F5gTqgRjBBRdKRM81bwVFaUmqnHsPWgAWaeLapZxmrnfRqC%2F--HGGLHoE3sfXKcP7z--LfDlG3VIbZ0LSjwFoGl%2Bmw%3D%3D; _forum_session=NtilsRG2mkgUOmJGGgmGuCf4cGtxPHLLtE7sRkaRYP1gm6KA79fk6s6%2BBhYNTjoQz92x7pZljg9x1bGZYOTjuVDhzmeq5x7i7do7m3Iu4Z9jS6dSVGNJPaMi0p4uxHuqS4dfRLZ4JAODWZasTskcLq4gGXVUCOdybif89cg3dKNDyW3PAs%2Fp0D0uIRhWHJ49ws2uOQKbXVBvITyNdkKB7Ki%2BCTtLn8oCeTuq6rVxXcXuuaDh8jSz1CC3Cjw1I2jRVzm7ZVWdJMwRWCFbMb88AEGm2Mdh2Qx%2Fjwcexa6taXPuXR2LBuaUij5VmkRIzo0iRWya%2BJPVwhYR2jUJm9XR9cHKA6MUd87r%2FElyO9Aae7Vj0xP4ICt3KERZHUsidg%3D%3D--ZoSVywr0%2BfmX4s8w--E4TO4wELmgx%2BPdtHfufj2w%3D%3D; __profilin=p%3Dt%2Ca%3D6f2394e0167f915ab2fc46e5a6d45127%7C034d5170cc7d54c26ede324b2850a654
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Sec-GPC: 1
Pragma: no-cache
Cache-Control: no-cache


Response:
HTTP/1.1 500 Internal Server Error
Server: nginx/1.22.0
Date: Tue, 14 Jun 2022 04:08:05 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 658
Connection: keep-alive
X-Request-Id: d39e6252-1034-4e72-ae96-d20ebdb3a59e
Set-Cookie: __profilin=p%3Dt%2Ca%3D6f2394e0167f915ab2fc46e5a6d45127%7C034d5170cc7d54c26ede324b2850a654; path=/; secure; HttpOnly; SameSite=Lax
X-Runtime: 0.550344

So sorry for all the trouble. Again let me know if I can be helpful.

Best wishes,
Henry Laxen

I would not intepret that discussion to form that timeline; my reply was more to get more eyes to move along that issue, I’m not sure it LibreTranslate will be merged that quickly. :slight_smile:

Hi Henry,
yes the internal server error comes from the SUPPORTED_LANG_MAPPING problem,
I’ve just mentioned it to author of the PR.

Dear Maiki,
I see. If I were to switch to your branch, do I just clone your repository, fix up app.yml, and rebuild, or is there more to it. I live in Tijuana, so running a discourse instance without English and Spanish is a game stopper for me. Thanks for the responses.