tessl install tessl/pypi-googletrans@4.0.0An unofficial Google Translate API for Python providing free text translation and language detection capabilities
Agent Success
Agent success rate when using this tile
100%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.01x
Baseline
Agent success rate without this tile
99%
Build a content processor that handles translation and language detection with proper type annotations.
Implement a ContentProcessor class that:
import typing
from googletrans import Translator, Translated, Detected
class ContentProcessor:
"""Processes content with translation and detection capabilities."""
def __init__(self, target_lang: str = "en") -> None:
"""
Initialize the content processor.
Args:
target_lang: Default target language for translations
"""
pass
async def translate_content(
self,
content: typing.Union[str, typing.List[str]],
dest: str = None
) -> typing.Union[Translated, typing.List[Translated]]:
"""
Translate content to target language.
Args:
content: Text or list of texts to translate
dest: Destination language (uses default if None)
Returns:
Single Translated object for string input,
List of Translated objects for list input
"""
pass
async def detect_languages(
self,
content: typing.Union[str, typing.List[str]]
) -> typing.Union[Detected, typing.List[Detected]]:
"""
Detect language(s) of content.
Args:
content: Text or list of texts to detect
Returns:
Single Detected object for string input,
List of Detected objects for list input
"""
pass
async def close(self) -> None:
"""Clean up resources."""
passTranslated object with text "Hola mundo" @testTranslated objects @testDetected object with lang="fr" @testDetected objects @test@generates
Provides translation and language detection with type-safe APIs.