Google Translate API

Apps

Configuration of Google Translate API app

class integreat_cms.google_translate_api.apps.GoogleTranslateApiClientConfig(app_name, app_module)[source]

Bases: AppConfig

Google Translate API config inheriting the django AppConfig

name: Final[str] = 'integreat_cms.google_translate_api'[source]

Full Python path to the application

ready() None[source]

Checking if API is available

Return type:

None

ready_v2(credentials: Credentials) None[source]

Preparing Google Translate with basic version

Parameters:

credentials (Credentials) –

Return type:

None

ready_v3(credentials: Credentials) None[source]

Preparing Google Translate with advanced version

Parameters:

credentials (Credentials) –

Return type:

None

supported_source_languages: list[str] = [][source]

The supported source languages

supported_target_languages: list[str] = [][source]

The supported target languages

verbose_name: Final[Promise] = 'Google Translate API'[source]

Human-readable name for the application

Google Translate API Client

class integreat_cms.google_translate_api.google_translate_api_client.GoogleTranslateApiClient(request: HttpRequest, form_class: ModelFormMetaclass)[source]

Bases: MachineTranslationApiClient

Google Translate API client to automatically translate selected objects.

Parameters:
  • request (HttpRequest) –

  • form_class (ModelFormMetaclass) –

__init__(request: HttpRequest, form_class: ModelFormMetaclass) None[source]

Initialize the Google Translate client

Parameters:
  • region – The current region

  • form_class (ModelFormMetaclass) – The CustomContentModelForm subclass of the current content type

  • request (HttpRequest) –

Return type:

None

static get_target_language_key(target_language: Language) str[source]

This function decides the correct target language key

Parameters:

target_language (Language) – the target language

Returns:

target_language_key which is 2 characters long for all languages except English and Portugese where the BCP tag is transmitted

Return type:

str

translate_queryset(queryset: list[Event] | list[Page] | list[POI], language_slug: str) None[source]

This function translates a content queryset via Google Translate

Parameters:
Return type:

None

Google Translate Provider

class integreat_cms.google_translate_api.google_translate_provider.GoogleTranslateProvider[source]

Bases: MachineTranslationProvider

The provider for Google machine translations

api_client[source]

The API client class for this provider

alias of GoogleTranslateApiClient

enabled: bool = False[source]

Whether the provider is globally enabled

name: str = 'Google Translate'[source]

The readable name for this provider

supported_source_languages: list[str] = [][source]

The supported source languages

supported_target_languages: list[str] = [][source]

The supported target languages