From 25b247cefe3b30e22a7d62c54c3b1cb1ea202810 Mon Sep 17 00:00:00 2001 From: Tharun-bot Date: Fri, 27 Feb 2026 23:29:06 +0530 Subject: [PATCH 1/4] feat(ai): add AI Translate Strings endpoint support --- crowdin_api/api_resources/ai/resource.py | 27 +++++++++++++++++++ .../ai/tests/test_ai_resources.py | 22 +++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/crowdin_api/api_resources/ai/resource.py b/crowdin_api/api_resources/ai/resource.py index 38678c2..533fe9c 100644 --- a/crowdin_api/api_resources/ai/resource.py +++ b/crowdin_api/api_resources/ai/resource.py @@ -1315,3 +1315,30 @@ def list_supported_ai_provider_models( path="ai/providers/supported-models", params=params ) + + def ai_translate_strings( + self, + aiId: int, + projectId: int, + targetLanguageIds: Iterable[str], + stringIds: Optional[Iterable[int]] = None, + # add other params per the API docs + ): + """ + AI Translate Strings. + + Link to API docs: + https://developer.crowdin.com/api/v2/#tag/AI/operation/api.ai.translations.generate + """ + params = { + "projectId": projectId, + "targetLanguageIds": targetLanguageIds, + } + if stringIds is not None: + params["stringIds"] = stringIds + + return self.requester.request( + method="post", + path=f"ai/{aiId}/translate-strings", + post_data=params, + ) \ No newline at end of file diff --git a/crowdin_api/api_resources/ai/tests/test_ai_resources.py b/crowdin_api/api_resources/ai/tests/test_ai_resources.py index 4002abd..e69bcaf 100644 --- a/crowdin_api/api_resources/ai/tests/test_ai_resources.py +++ b/crowdin_api/api_resources/ai/tests/test_ai_resources.py @@ -2104,3 +2104,25 @@ def test_list_supported_ai_provider_models(self, m_request, in_params, request_p path="ai/providers/supported-models", params=request_params ) + + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_ai_translate_strings(self, m_request, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.ai_translate_strings( + aiId=1, + projectId=42, + targetLanguageIds=["uk", "fr"], + stringIds=[101, 102], + ) == "response" + + m_request.assert_called_once_with( + method="post", + path="ai/1/translate-strings", + post_data={ + "projectId": 42, + "targetLanguageIds": ["uk", "fr"], + "stringIds": [101, 102], + }, + ) From 14d969b331259021a8b6eab9ec0065ff088868e8 Mon Sep 17 00:00:00 2001 From: Tharun-bot Date: Fri, 27 Feb 2026 23:46:30 +0530 Subject: [PATCH 2/4] feat(ai): add AI Translate Strings endpoint support - intendation linting fixed! --- crowdin_api/api_resources/ai/resource.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crowdin_api/api_resources/ai/resource.py b/crowdin_api/api_resources/ai/resource.py index 533fe9c..6d37a50 100644 --- a/crowdin_api/api_resources/ai/resource.py +++ b/crowdin_api/api_resources/ai/resource.py @@ -1317,12 +1317,12 @@ def list_supported_ai_provider_models( ) def ai_translate_strings( - self, - aiId: int, - projectId: int, - targetLanguageIds: Iterable[str], - stringIds: Optional[Iterable[int]] = None, - # add other params per the API docs + self, + aiId: int, + projectId: int, + targetLanguageIds: Iterable[str], + stringIds: Optional[Iterable[int]] = None, + # add other params per the API docs ): """ AI Translate Strings. From 92f3268a0951ee190e3d4bfc4f5f10d3d9957d1d Mon Sep 17 00:00:00 2001 From: Tharun-bot Date: Fri, 27 Feb 2026 23:59:53 +0530 Subject: [PATCH 3/4] fix(ai): fix flake8 linting errors in ai_translate_strings --- crowdin_api/api_resources/ai/resource.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crowdin_api/api_resources/ai/resource.py b/crowdin_api/api_resources/ai/resource.py index 6d37a50..1e43e0b 100644 --- a/crowdin_api/api_resources/ai/resource.py +++ b/crowdin_api/api_resources/ai/resource.py @@ -1320,25 +1320,25 @@ def ai_translate_strings( self, aiId: int, projectId: int, - targetLanguageIds: Iterable[str], - stringIds: Optional[Iterable[int]] = None, - # add other params per the API docs + targetLanguageIds, + stringIds=None, ): """ AI Translate Strings. - + Link to API docs: https://developer.crowdin.com/api/v2/#tag/AI/operation/api.ai.translations.generate """ - params = { - "projectId": projectId, - "targetLanguageIds": targetLanguageIds, + post_data = { + "projectId": projectId, + "targetLanguageIds": targetLanguageIds, } if stringIds is not None: - params["stringIds"] = stringIds + post_data["stringIds"] = stringIds return self.requester.request( method="post", path=f"ai/{aiId}/translate-strings", - post_data=params, - ) \ No newline at end of file + post_data=post_data, + ) + \ No newline at end of file From f54d06d5a0ca95cf3da259489e7909860a962df6 Mon Sep 17 00:00:00 2001 From: Tharun-bot Date: Sat, 28 Feb 2026 00:02:10 +0530 Subject: [PATCH 4/4] fix(ai): fix flake8 linting errors --- crowdin_api/api_resources/ai/resource.py | 1 - 1 file changed, 1 deletion(-) diff --git a/crowdin_api/api_resources/ai/resource.py b/crowdin_api/api_resources/ai/resource.py index 1e43e0b..14184d8 100644 --- a/crowdin_api/api_resources/ai/resource.py +++ b/crowdin_api/api_resources/ai/resource.py @@ -1341,4 +1341,3 @@ def ai_translate_strings( path=f"ai/{aiId}/translate-strings", post_data=post_data, ) - \ No newline at end of file