Translator-GO-Endpoint/scripts/python/package_mangement/downlaod_languages.py

19 lines
615 B
Python
Raw Normal View History

import argostranslate.translate
import argostranslate.package
def install_language(from_code, to_code):
try:
argostranslate.package.update_package_index()
available_packages = argostranslate.package.get_available_packages()
available_package = list(
filter(
lambda x: x.from_code == from_code and x.to_code == to_code, available_packages
)
)[0]
download_path = available_package.download()
argostranslate.package.install_from_path(download_path)
return 0
except Exception:
return 1