An unofficial Google Translate API for Python providing free text translation and language detection capabilities
Overall
score
100%
Evaluation — 100%
↑ 1.01xAgent success when using this tile
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.
Install with Tessl CLI
npx tessl i tessl/pypi-googletrans@4.0.0docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10