CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-googletrans

An unofficial Google Translate API for Python providing free text translation and language detection capabilities

Overall
score

100%

Evaluation100%

1.01x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-7/

Multi-Environment Translation Service

Build a translation service that works across different deployment environments with configurable translator settings.

Overview

Your task is to create a translation service module that initializes translators with different configurations based on environment requirements. The service should support multiple deployment scenarios (production, testing, and restricted networks) with appropriate translator settings.

Requirements

Create a Python module that provides translator instances configured for three different environments:

Production Translator

  • Uses the stable Google API endpoint for reliability
  • Enables HTTP/2 for better performance
  • Uses default error handling (returns None on failures rather than raising exceptions)

Development Translator

  • Uses the standard Google Translate web endpoint
  • Raises exceptions on errors for easier debugging
  • Uses a custom user agent string: "DevBot/1.0"

Restricted Network Translator

  • Uses an alternative regional endpoint: "translate.google.co.kr"
  • Disables HTTP/2 for compatibility with older network infrastructure
  • Raises exceptions on errors

Service Interface

Implement a function get_translator(environment: str) that returns an appropriately configured translator instance based on the environment parameter. The function should accept "production", "development", or "restricted" as valid environment values.

Test Cases

  • When requesting a "production" translator, it returns a translator configured with the googleapis endpoint and HTTP/2 enabled @test
  • When requesting a "development" translator, it returns a translator with raise_exception enabled and custom user agent @test
  • When requesting a "restricted" translator, it returns a translator using the Korean endpoint with HTTP/2 disabled @test
  • When requesting an invalid environment name, it raises a ValueError @test

@generates

API

def get_translator(environment: str):
    """
    Returns a configured translator instance for the specified environment.

    Args:
        environment: One of "production", "development", or "restricted"

    Returns:
        A configured Translator instance

    Raises:
        ValueError: If environment is not recognized
    """
    pass

Dependencies { .dependencies }

googletrans { .dependency }

Provides translation services via Google Translate API.

Install with Tessl CLI

npx tessl i tessl/pypi-googletrans@4.0.0

tile.json