Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(translations): support for missing params #161

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
OmAximani0 marked this conversation as resolved.
Show resolved Hide resolved
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]