Deepl API

Apps

Configuration of DeepL API app

class integreat_cms.deepl_api.apps.DeepLApiClientConfig(app_name, app_module)[source]

Bases: AppConfig

DeepL API config inheriting the django AppConfig

static assert_usage_limit_not_reached(translator: Translator) None[source]

Requests the usage from the translator and asserts that no limit was reached

Parameters:

translator (Translator) – The deepl translator

Return type:

None

get_glossary(source_language: str, target_language: str) GlossaryInfo | None[source]

Looks up a glossary for the specified source language and target language pair. This method also returns the correct glossary for region variants (for example en-gb)

Parameters:
  • source_language (str) – The source language

  • target_language (str) – The target language

Returns:

A GlossaryInfo object or None

Return type:

GlossaryInfo | None

init_supported_glossaries(translator: Translator) None[source]

Requests the supported glossaries from the translator and sets them

Parameters:

translator (Translator) – The deepl translator

Return type:

None

init_supported_source_languages(translator: Translator) None[source]

Requests the supported sources languages from the translator and sets them

Parameters:

translator (Translator) – The deepl translator

Return type:

None

init_supported_target_languages(translator: Translator) None[source]

Requests the supported target languages from the translator and sets them

Parameters:

translator (Translator) – The deepl translator

Return type:

None

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

Full Python path to the application

ready() None[source]

Checking if API is available

Return type:

None

supported_glossaries: dict[tuple[str, str], GlossaryInfo] = {}[source]

The supported glossaries, a map from (source_language, target_language) to glossary info

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

The supported source languages

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

The supported target languages

verbose_name: Final[Promise] = 'DeepL API'[source]

Human-readable name for the application

Deepl API Client

class integreat_cms.deepl_api.deepl_api_client.DeepLApiClient(request: HttpRequest, form_class: ModelFormMetaclass)[source]

Bases: MachineTranslationApiClient

DeepL API client to automatically translate selected objects.

Parameters:
  • request (HttpRequest)

  • form_class (ModelFormMetaclass)

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

Initialize the DeepL 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 DeepL

Parameters:
Return type:

None

Deepl Provider

class integreat_cms.deepl_api.deepl_provider.DeepLProvider[source]

Bases: MachineTranslationProvider

The provider for DeepL machine translations

api_client[source]

The API client class for this provider

alias of DeepLApiClient

enabled: bool = False[source]

Whether the provider is globally enabled

name: str = 'DeepL'[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