Skip to main content

translate-html

Translate HTML using Beautiful Soup and Argos Translate

Install

pip install translatehtml

Example

import argostranslate.package, argostranslate.translate
import translatehtml

from_code = "es"
to_code = "en"

html_doc = """<div><h1>Perro</h1></div>"""

# Download and install Argos Translate package
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)

# Translate
installed_languages = argostranslate.translate.get_installed_languages()
from_lang = list(filter(lambda x: x.code == from_code, installed_languages))[0]
to_lang = list(filter(lambda x: x.code == to_code, installed_languages))[0]

translation = from_lang.get_translation(to_lang)

translated_soup = translatehtml.translate_html(translation, html_doc)

print(translated_soup)

Links

Metadata

Release files for translatehtml 1.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for translatehtml 1.5.3
File Size Uploaded
translatehtml-1.5.3.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for translatehtml 1.5.3
File Interpreter ABI Platform
translatehtml-1.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / translatehtml-1.5.3.tar.gz

Download URL translatehtml-1.5.3.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eeb2177ac4836d33fc15ebf4bfd5435ca4f082d9518dcafff743bfad43413354
BLAKE2b-256 checksum
How to use checksums
a67811a9b1e72b98dd895f14b6da1e3a26250423625e703eecd013d2b597c7f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Release files / translatehtml-1.5.3-py3-none-any.whl

Download URL translatehtml-1.5.3-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a42a9d1fd5381920a5a350b5869079df821068c26709d912d8b9f3313a5bafa0
BLAKE2b-256 checksum
How to use checksums
3899ca0616b9bf07db740aad52730a6f7e3abf88c14b4d7759af6d139fa53a1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.5.3 This release

2 release files

1.5.2

2 release files

1.5.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page