Libre Translate installation on a webserver?

I’m looking into the possibility of replacing the defunct free Google Translate API with self-hosted Libre Translate.
I integrated the GT API within the webpage, by using a javascript library, and then placing buttons to call the translations of html elements, like this:

<script>
function googleSectionalElementInit() {
  new google.translate.SectionalElement({
    sectionalNodeClassName: 'goog-trans-section',
    controlNodeClassName: 'goog-trans-control',
  }, 'google_sectional_element');
}
</script>

and then a button :
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=en"></script>
<a href="javascript:void(0)"><span class="goog-trans-control"></span></a>

Ideally, I would like to use Libre Translate in the same way.

I skimmed Libre Translate docs for a bit, but I’m still unsure on how to proceed.

My webserver is a standard LAMP, Ubuntu with PHP, Apache.
I use composer.

First, what are resource requirements ?
Will my small webserver be able to run it ? (volume should be low, below 10 translations/minute)

Then, how to install and get the self-hosted API up and running ?

Is there a javascript library to invoke it in a similar way to google translate ?

Thank you for your help.

1 Like

Have you checked out the instructions on GitHub - LibreTranslate/LibreTranslate: Free and Open Source Machine Translation API. Self-hosted, offline capable and easy to setup. ?

If you’re using Apache, you can probably setup a reverse proxy as instructed on GitHub - LibreTranslate/LibreTranslate: Free and Open Source Machine Translation API. Self-hosted, offline capable and easy to setup.

2 Likes

Thank you, I will try to get somewhere with that.

I don’t use Docker, and I develop my websites on a simple WAMP setup before putting them on a similar standard LAMP hosting (plesk obsidian).
I prefer complete and straightforward instructions because implied stuff is confusing me.

The POST/GET stuff is simple because there is no ambiguity about anything, but for example in the “API examples” here: https://github.com/LibreTranslate/LibreTranslate#api-examples
it doesn’t even say what language this is - I guess it’s JS, but just for the sake of the argument …

another thought I just had is that I want to restrict these API calls to content on my website. so, when a user visits and clicks that button, the translation will be fetched by javascript in his browser. How to make sure only visitors of my website can do that ?

still trying to figure this out.

a comprehensive list of system requirements would help. does the self hosted API require python ?
will libretranslate API work on a plesk obsidian hosting ?