From a850ae3d80e104f3720cddf0de05d5bbd4fb6a7f Mon Sep 17 00:00:00 2001 From: Om Aximani <75031769+OmAximani0@users.noreply.github.com> Date: Mon, 27 May 2024 14:28:30 +0530 Subject: [PATCH] feat(translations): support for missing params (#161) --- crowdin_api/api_resources/translations/enums.py | 1 + crowdin_api/api_resources/translations/resource.py | 10 ++++++++++ .../translations/tests/test_translations_resources.py | 9 +++++++++ crowdin_api/api_resources/translations/types.py | 7 +++++++ 4 files changed, 27 insertions(+) create mode 100644 crowdin_api/api_resources/translations/types.py diff --git a/crowdin_api/api_resources/translations/enums.py b/crowdin_api/api_resources/translations/enums.py index 8dc2a92..ee4c7e8 100644 --- a/crowdin_api/api_resources/translations/enums.py +++ b/crowdin_api/api_resources/translations/enums.py @@ -4,6 +4,7 @@ class PreTranslationApplyMethod(Enum): TM = "tm" MT = "mt" + AI = "ai" class PreTranslationAutoApproveOption(Enum): diff --git a/crowdin_api/api_resources/translations/resource.py b/crowdin_api/api_resources/translations/resource.py index f478d46..26ea76c 100644 --- a/crowdin_api/api_resources/translations/resource.py +++ b/crowdin_api/api_resources/translations/resource.py @@ -2,6 +2,7 @@ from crowdin_api.api_resources.abstract.resources import BaseResource from crowdin_api.api_resources.enums import ExportProjectTranslationFormat +from crowdin_api.api_resources.translations.types import FallbackLanguages from crowdin_api.api_resources.translations.enums import ( CharTransformation, PreTranslationApplyMethod, @@ -54,10 +55,13 @@ def apply_pre_translation( projectId: Optional[int] = None, method: Optional[PreTranslationApplyMethod] = None, engineId: Optional[int] = None, + aiPromptId: Optional[int] = None, autoApproveOption: Optional[PreTranslationAutoApproveOption] = None, duplicateTranslations: Optional[bool] = None, + skipApprovedTranslations: Optional[bool] = None, translateUntranslatedOnly: Optional[bool] = None, translateWithPerfectMatchOnly: Optional[bool] = None, + fallbackLanguages: Optional[Iterable[FallbackLanguages]] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = None, ): @@ -67,6 +71,9 @@ def apply_pre_translation( Link to documentation: https://developer.crowdin.com/api/v2/#operation/api.projects.pre-translations.post """ + if fallbackLanguages is None: + fallbackLanguages = [] + if labelIds is None: labelIds = [] @@ -83,10 +90,13 @@ def apply_pre_translation( "fileIds": fileIds, "method": method, "engineId": engineId, + "aiPromptId": aiPromptId, "autoApproveOption": autoApproveOption, "duplicateTranslations": duplicateTranslations, + "skipApprovedTranslations": skipApprovedTranslations, "translateUntranslatedOnly": translateUntranslatedOnly, "translateWithPerfectMatchOnly": translateWithPerfectMatchOnly, + "fallbackLanguages": fallbackLanguages, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, }, diff --git a/crowdin_api/api_resources/translations/tests/test_translations_resources.py b/crowdin_api/api_resources/translations/tests/test_translations_resources.py index 264b160..1e44965 100644 --- a/crowdin_api/api_resources/translations/tests/test_translations_resources.py +++ b/crowdin_api/api_resources/translations/tests/test_translations_resources.py @@ -48,10 +48,13 @@ def test_list_project_branches(self, m_request, base_absolut_url): "fileIds": [1, 2], "method": None, "engineId": None, + "aiPromptId": None, "autoApproveOption": None, "duplicateTranslations": None, + "skipApprovedTranslations": None, "translateUntranslatedOnly": None, "translateWithPerfectMatchOnly": None, + "fallbackLanguages": [], "labelIds": [], "excludeLabelIds": [], }, @@ -62,10 +65,13 @@ def test_list_project_branches(self, m_request, base_absolut_url): "fileIds": [1, 2], "method": PreTranslationApplyMethod.MT, "engineId": 3, + "aiPromptId": 0, "autoApproveOption": PreTranslationAutoApproveOption.ALL, "duplicateTranslations": False, + "skipApprovedTranslations": False, "translateUntranslatedOnly": False, "translateWithPerfectMatchOnly": False, + "fallbackLanguages": ["lang"], "labelIds": [1], "excludeLabelIds": [1], }, @@ -74,10 +80,13 @@ def test_list_project_branches(self, m_request, base_absolut_url): "fileIds": [1, 2], "method": PreTranslationApplyMethod.MT, "engineId": 3, + "aiPromptId": 0, "autoApproveOption": PreTranslationAutoApproveOption.ALL, "duplicateTranslations": False, + "skipApprovedTranslations": False, "translateUntranslatedOnly": False, "translateWithPerfectMatchOnly": False, + "fallbackLanguages": ["lang"], "labelIds": [1], "excludeLabelIds": [1], }, diff --git a/crowdin_api/api_resources/translations/types.py b/crowdin_api/api_resources/translations/types.py new file mode 100644 index 0000000..eea6ee9 --- /dev/null +++ b/crowdin_api/api_resources/translations/types.py @@ -0,0 +1,7 @@ +from typing import Iterable + +from crowdin_api.typing import TypedDict + + +class FallbackLanguages(TypedDict): + languageId: Iterable[str]