LibreTranslate is a machine translation API which is entirely self-hosted. This software lets you use open source machine translation in your projects. It uses Argos Translate for its translation engine.
It supports quite a few commonly used languages, but for example, for my own country it only supports English and none of the other 10 official languages. They provide two links at the end of the review to a test site as well as the open source code project. When I tested it for English to Dutch, it did not recognise everything and showed about 95% accuracy. So not quite in Google's league, but if you want a free and self-hosted alternative then it does do a pretty good job.
That said, to add new languages, you first need to train an Argos Translate model. They provide a video link for details. First you need to collect data, for example from Opus, then you need to add the data to data-index.json in the Argos Train repo.
I see also you can enable all languages by turning on --debug mode, which includes the non-reviewed languages too.
If you don't want to self-host, you can also opt to use their cloud API for production use for a fee. But a docker image is available, which would make self-hosting pretty simple.
See Machine Learning in Linux: LibreTranslate is Self-hosted Machine Translation - LinuxLinks
LibreTranslate is a machine translation API which is entirely self-hosted. This software lets you use machine translation in your projects.