Skip to content

Commit

Permalink
feat: Support for includePreTranslatedStringsOnly (#124)
Browse files Browse the repository at this point in the history
- Added other missing params
- Added missing functions

Signed-off-by: OmAxiani0 <[email protected]>
  • Loading branch information
OmAximani0 authored Oct 6, 2023
1 parent bf93c3b commit 8bbc6a6
Show file tree
Hide file tree
Showing 3 changed files with 329 additions and 0 deletions.
28 changes: 28 additions & 0 deletions crowdin_api/api_resources/tasks/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class CrowdinTaskStatus(Enum):
CLOSED = "closed"


# Language Service
class LanguageServiceTaskType(Enum):
TRANSLATE_BY_VENDOR = 2
PROOFREAD_BY_VENDOR = 3


# Oht
class OhtCrowdinTaskType(Enum):
TRANSLATE_BY_VENDOR = 2
Expand Down Expand Up @@ -153,3 +159,25 @@ class TranslatedCrowdinTaskSubjects(Enum):
SOCIAL_SCIENCE = "social_science"
TELECOMMUNICATIONS = "telecommunications"
TRAVEL_TOURISM = "travel_tourism"


# Manual
class ManualCrowdinTaskType(Enum):
TRANSLATE_BY_VENDOR = 2
PROOFREAD_BY_VENDOR = 3


class ManualCrowdinVendors(Enum):
ALCONOST = "alconost"
BABBLE_ON = "babbleon"
TOMEDES = "tomedes"
E2F = "e2f"
WRITE_PATH = "write_path_admin"
INLINGO = "inlingo"
ACCLARO = "acclaro"
TRANSLATE_BY_HUMANS = "translate_by_humans"
LINGO24 = "lingo24"
ASSERTIO_LANGUAGE_SERVICE = "assertio_language_services"
GTE_LOCALIZE = "gte_localize"
KETTU_SOLUTIONS = "kettu_solutions"
LANGUAGELINE_TRANSLATION_SOLUTIONS = "languageline_solutions"
116 changes: 116 additions & 0 deletions crowdin_api/api_resources/tasks/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from crowdin_api.api_resources.tasks.enums import (
CrowdinGeneralTaskType,
CrowdinTaskStatus,
LanguageServiceTaskType,
GengoCrowdinTaskExpertise,
GengoCrowdinTaskPurpose,
GengoCrowdinTaskTone,
Expand All @@ -14,6 +15,8 @@
TranslatedCrowdinTaskExpertise,
TranslatedCrowdinTaskSubjects,
TranslatedCrowdinTaskType,
ManualCrowdinTaskType,
ManualCrowdinVendors,
)
from crowdin_api.api_resources.tasks.types import (
CrowdinTaskAssignee,
Expand Down Expand Up @@ -209,9 +212,12 @@ def add_general_task(
splitFiles: Optional[bool] = None,
skipAssignedStrings: Optional[bool] = None,
skipUntranslatedStrings: Optional[bool] = None,
includePreTranslatedStringsOnly: Optional[bool] = None,
labelIds: Optional[Iterable[int]] = None,
excludeLabelIds: Optional[Iterable[int]] = None,
assignees: Optional[Iterable[CrowdinTaskAssignee]] = None,
deadline: Optional[datetime] = None,
startedAt: Optional[datetime] = None,
dateFrom: Optional[datetime] = None,
dateTo: Optional[datetime] = None,
):
Expand All @@ -234,14 +240,61 @@ def add_general_task(
"splitFiles": splitFiles,
"skipAssignedStrings": skipAssignedStrings,
"skipUntranslatedStrings": skipUntranslatedStrings,
"includePreTranslatedStringsOnly": includePreTranslatedStringsOnly,
"labelIds": labelIds,
"excludeLabelIds": excludeLabelIds,
"assignees": assignees,
"deadline": deadline,
"startedAt": startedAt,
"dateFrom": dateFrom,
"dateTo": dateTo,
},
)

def add_language_service_task(
self,
projectId: int,
title: str,
languageId: str,
fileIds: Iterable[str],
type: LanguageServiceTaskType,
status: Optional[CrowdinTaskStatus] = None,
description: Optional[str] = None,
labelIds: Optional[Iterable[int]] = None,
excludeLabelIds: Optional[Iterable[int]] = None,
skipUntranslatedStrings: Optional[bool] = None,
includePreTranslatedStringsOnly: Optional[bool] = None,
includeUntranslatedStringsOnly: Optional[bool] = None,
dateFrom: Optional[datetime] = None,
dateTo: Optional[datetime] = None,
):
"""
Add Task(Crowdin Language Service Task Create Form).
Link to documentation:
https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post
"""

return self.add_task(
projectId=projectId,
request_data={
"title": title,
"languageId": languageId,
"fileIds": fileIds,
"type": type,
"vendor": "crowdin_language_service",
"status": status,
"description": description,
"labelIds": labelIds,
"excludeLabelIds": excludeLabelIds,
"skipUntranslatedStrings": skipUntranslatedStrings,
"includePreTranslatedStringsOnly": includePreTranslatedStringsOnly,
"includeUntranslatedStringsOnly": includeUntranslatedStringsOnly,
"dateFrom": dateFrom,
"dateTo": dateTo,
}
)

def add_vendor_oht_task(
self,
projectId: int,
Expand All @@ -253,6 +306,10 @@ def add_vendor_oht_task(
description: Optional[str] = None,
expertise: Optional[OhtCrowdinTaskExpertise] = None,
labelIds: Optional[Iterable[int]] = None,
excludeLabelIds: Optional[Iterable[int]] = None,
skipUntranslatedStrings: Optional[bool] = None,
includePreTranslatedStringsOnly: Optional[bool] = None,
includeUntranslatedStringsOnly: Optional[bool] = None,
dateFrom: Optional[datetime] = None,
dateTo: Optional[datetime] = None,
):
Expand All @@ -274,6 +331,10 @@ def add_vendor_oht_task(
"description": description,
"expertise": expertise,
"labelIds": labelIds,
"excludeLabelIds": excludeLabelIds,
"skipUntranslatedStrings": skipUntranslatedStrings,
"includePreTranslatedStringsOnly": includePreTranslatedStringsOnly,
"includeUntranslatedStringsOnly": includeUntranslatedStringsOnly,
"dateFrom": dateFrom,
"dateTo": dateTo,
"vendor": "oht",
Expand All @@ -296,6 +357,7 @@ def add_vendor_gengo_task(
usePreferred: Optional[bool] = None,
editService: Optional[bool] = None,
labelIds: Optional[Iterable[int]] = None,
excludeLabelIds: Optional[Iterable[int]] = None,
dateFrom: Optional[datetime] = None,
dateTo: Optional[datetime] = None,
):
Expand All @@ -322,6 +384,7 @@ def add_vendor_gengo_task(
"usePreferred": usePreferred,
"editService": editService,
"labelIds": labelIds,
"excludeLabelIds": excludeLabelIds,
"dateFrom": dateFrom,
"dateTo": dateTo,
"vendor": "gengo",
Expand All @@ -340,6 +403,7 @@ def add_vendor_translated_task(
expertise: Optional[TranslatedCrowdinTaskExpertise] = None,
subject: Optional[TranslatedCrowdinTaskSubjects] = None,
labelIds: Optional[Iterable[int]] = None,
excludeLabelIds: Optional[Iterable[int]] = None,
dateFrom: Optional[datetime] = None,
dateTo: Optional[datetime] = None,
):
Expand All @@ -361,12 +425,64 @@ def add_vendor_translated_task(
"expertise": expertise,
"subject": subject,
"labelIds": labelIds,
"excludeLabelIds": excludeLabelIds,
"dateFrom": dateFrom,
"dateTo": dateTo,
"vender": "translated",
},
)

def add_vendor_manual_task(
self,
projectId: int,
title: str,
languageId: str,
fileIds: Iterable[int],
type: ManualCrowdinTaskType,
vendor: ManualCrowdinVendors,
status: Optional[CrowdinTaskStatus] = None,
description: Optional[str] = None,
skipAssignedStrings: Optional[bool] = None,
skipUntranslatedStrings: Optional[bool] = None,
includePreTranslatedStringsOnly: Optional[bool] = None,
labelIds: Optional[Iterable[int]] = None,
excludeLabelIds: Optional[Iterable[int]] = None,
assignees: Optional[Iterable[CrowdinTaskAssignee]] = None,
deadline: Optional[datetime] = None,
startedAt: Optional[datetime] = None,
dateFrom: Optional[datetime] = None,
dateTo: Optional[datetime] = None,
):
"""
Add Task(Crowdin Vendor Manual Task Create Form).
Link to documentation:
https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post
"""

return self.add_task(
projectId=projectId,
request_data={
"title": title,
"languageId": languageId,
"fileIds": fileIds,
"type": type,
"vendor": vendor,
"status": status,
"description": description,
"skipAssignedStrings": skipAssignedStrings,
"skipUntranslatedStrings": skipUntranslatedStrings,
"includePreTranslatedStringsOnly": includePreTranslatedStringsOnly,
"labelIds": labelIds,
"excludeLabelIds": excludeLabelIds,
"assignees": assignees,
"deadline": deadline,
"startedAt": startedAt,
"dateFrom": dateFrom,
"dateTo": dateTo,
}
)

def export_task_strings(self, projectId: int, taskId: int):
"""
Export Task Strings.
Expand Down
Loading

0 comments on commit 8bbc6a6

Please sign in to comment.