-
Notifications
You must be signed in to change notification settings - Fork 40
feat(ai): add AI Translate Strings endpoint support #240
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
base: main
Are you sure you want to change the base?
Changes from all commits
25b247c
14d969b
92f3268
f54d06d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1315,3 +1315,29 @@ def list_supported_ai_provider_models( | |||||
| path="ai/providers/supported-models", | ||||||
| params=params | ||||||
| ) | ||||||
|
|
||||||
| def ai_translate_strings( | ||||||
| self, | ||||||
| aiId: int, | ||||||
| projectId: int, | ||||||
| targetLanguageIds, | ||||||
| stringIds=None, | ||||||
| ): | ||||||
| """ | ||||||
| AI Translate Strings. | ||||||
|
|
||||||
| Link to API docs: | ||||||
| https://developer.crowdin.com/api/v2/#tag/AI/operation/api.ai.translations.generate | ||||||
|
||||||
| https://developer.crowdin.com/api/v2/#tag/AI/operation/api.ai.translations.generate | |
| https://support.crowdin.com/developer/enterprise/api/v2/#tag/AI/operation/api.ai.translate-strings.enterprise.generate |
Copilot
AI
Feb 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIRequester.request() does not accept a post_data keyword (it only supports request_data), so this will raise a TypeError at runtime when the request is executed. Please rename post_data to request_data here (and keep the dict as-is).
| post_data=post_data, | |
| request_data=post_data, |
Copilot
AI
Feb 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description says this adds support for the Crowdin API "AI Translate Strings" endpoint (linked under the non-enterprise docs), but the implementation is currently only on EnterpriseAIResource and uses the enterprise-style path (no users/{userId} prefix). Please confirm whether this endpoint is enterprise-only; if it’s part of the standard API as well, the method (and tests) likely need to be added to AIResource with the correct path/params, or the PR description should be updated to reflect enterprise scope.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Comment on lines
+2112
to
+2118
|
||
|
|
||
| m_request.assert_called_once_with( | ||
| method="post", | ||
| path="ai/1/translate-strings", | ||
| post_data={ | ||
| "projectId": 42, | ||
| "targetLanguageIds": ["uk", "fr"], | ||
| "stringIds": [101, 102], | ||
| }, | ||
| ) | ||
|
Comment on lines
+2120
to
+2128
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
targetLanguageIdsandstringIdsare missing type hints here, while other resource methods typically annotate these asOptional[Iterable[str]]/Optional[Iterable[int]]. Adding explicit types (and makingstringIdsanOptional[...]) will improve IDE/autocomplete support and make the public API clearer.