/
deepl_provider.py
45 lines (34 loc) · 1.21 KB
/
deepl_provider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import annotations
import logging
from django.apps import apps
from django.conf import settings
from django.utils.functional import classproperty
from ..core.utils.machine_translation_provider import MachineTranslationProvider
from .deepl_api_client import DeepLApiClient
logger = logging.getLogger(__name__)
class DeepLProvider(MachineTranslationProvider):
"""
The provider for DeepL machine translations
"""
#: The readable name for this provider
name = "DeepL"
#: The API client class for this provider
api_client = DeepLApiClient
#: Whether the provider is globally enabled
enabled = settings.DEEPL_ENABLED
@classmethod
@classproperty
def supported_source_languages(cls) -> list[str]:
"""
The supported source languages
:return: The list of supported source languages
"""
return apps.get_app_config("deepl_api").supported_source_languages
@classmethod
@classproperty
def supported_target_languages(cls) -> list[str]:
"""
The supported target languages
:return: The list of supported target languages
"""
return apps.get_app_config("deepl_api").supported_target_languages