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
- classmethod create(entry)[source]
Factory that creates an app config from an entry in INSTALLED_APPS.
- get_model(model_name, require_ready=True)[source]
Return the model with the given case-insensitive model_name.
Raise LookupError if no model exists with this name.
- get_models(include_auto_created=False, include_swapped=False)[source]
Return an iterable of models.
By default, the following models aren’t included:
auto-created models for many-to-many relations without an explicit intermediate table,
models that have been swapped out.
Set the corresponding keyword argument to True to include such models. Keyword arguments aren’t documented; they’re a private API.
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 typerequest (HttpRequest)
- Return type:
None
- check_usage(region: Region, source_translation: EventTranslation | PageTranslation | POITranslation) tuple[bool, int] [source]
This function checks if the attempted translation would exceed the region’s word limit
- Parameters:
region (Region) – region for which to check usage
source_translation (EventTranslation | (PageTranslation | POITranslation)) – single content object
- Returns:
translation would exceed limit, region budget, attempted translation word count
- Return type:
- static get_target_language_key(target_language: Language) str [source]
This function decides the correct target language key
- translate_object(obj: Event | Page | POI, language_slug: str) None [source]
This function translates one content object
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
- classmethod is_enabled(region: Region, language: Language) bool [source]
Whether this provider is enabled for a given region and language. Call this from the parent class.
- is_needed(queryset: QuerySet[Event | Page | POI], target_language: Language) list[Event | Page | POI] [source]
Checks if a machine translation is needed, thus checking if the translation status is UP_TO_DATE or MACHINE_TRANSLATED and then returns a lit of translations which are to be updated
- static is_permitted(region: Region, user: SimpleLazyObject, content_type: ModelBase) bool [source]
Checks if a machine translation is permitted, i.e. if for the given region, MT of the given content type is allowed and MT into the target language is enabled for the requesting user.