Skip to content

Commit

Permalink
feat(translations): support for missing params (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmAximani0 authored May 27, 2024
1 parent c4e4d9e commit a850ae3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions crowdin_api/api_resources/translations/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class PreTranslationApplyMethod(Enum):
TM = "tm"
MT = "mt"
AI = "ai"


class PreTranslationAutoApproveOption(Enum):
Expand Down
10 changes: 10 additions & 0 deletions crowdin_api/api_resources/translations/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
):
Expand All @@ -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 = []

Expand All @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
},
Expand All @@ -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],
},
Expand All @@ -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],
},
Expand Down
7 changes: 7 additions & 0 deletions crowdin_api/api_resources/translations/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from typing import Iterable

from crowdin_api.typing import TypedDict


class FallbackLanguages(TypedDict):
languageId: Iterable[str]

0 comments on commit a850ae3

Please sign in to comment.