Open-source offline translation library written in Python
Argos Translate uses OpenNMT for translations and can be used as either a Python library, command-line, or GUI application. Argos Translate supports installing language model packages which are zip archives with a ".argosmodel" extension containing the data needed for translation. LibreTranslate is an API and web-app built on top of Argos Translate.
import argostranslate.package
import argostranslate.translate
from_code = "en"
to_code = "es"
# Download and install Argos Translate package
argostranslate.package.update_package_index()
available_packages = argostranslate.package.get_available_packages()
package_to_install = next(
filter(
lambda x: x.from_code == from_code and x.to_code == to_code, available_packages
)
)
argostranslate.package.install_from_path(package_to_install.download())
# Translate
translatedText = argostranslate.translate.translate("Hello World", from_code, to_code)
print(translatedText)
# '¡Hola Mundo!'
$ argos-translate --from-lang en --to-lang es "Hello World"
Hola Mundo
$ echo "Text to translate" | argos-translate --from-lang en --to-lang es
Texto para traducir
const res = await fetch("https://translate.argosopentech.com/translate", {
method: "POST",
body: JSON.stringify({
q: "Hello!",
source: "en",
target: "es"
}),
headers: {
"Content-Type": "application/json"}
});
console.log(await res.json());
// {
// "translatedText": "¡Hola!"
// }
I give away all of the Argos Translate code for free under a permissive license meaning anyone in the world can use the software free of charge. Although I enjoy building and maintaining open source software it is a lot of thankless work and I need to generate income for Argos Translate to be sustainable. Donations are greatly appreciated
You can also support me by buying VPS hosting through my affiliate links. I have used and highly recommend all of these hosting providers.
I’m also available for hire! I do software development contracting and can help you develop or maintain software. I have experience with Python, C++, Android, Linux, Machine Translation, Qt, Web Development, and more. I am also a quick learner and could help with many different types of IT tasks.