-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - crowdin #14447
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
Merged
Merged
New Components - crowdin #14447
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import fs from "fs"; | ||
| import { TYPE_OPTIONS } from "../../common/constants.mjs"; | ||
| import { | ||
| checkTmp, | ||
| parseObject, | ||
| } from "../../common/utils.mjs"; | ||
| import crowdin from "../../crowdin.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "crowdin-add-file", | ||
| name: "Add File to Project", | ||
| description: "Adds a file into the created project. [See the documentation](https://developer.crowdin.com/api/v2/#tag/source-files/operation/api.projects.files.post)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| crowdin, | ||
| projectId: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "projectId", | ||
| ], | ||
| }, | ||
| file: { | ||
| type: "string", | ||
| label: "File", | ||
| description: "The path to the file saved to the `/tmp` directory (e.g. `/tmp/example.jpg`) to process. [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).", | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "The name of the file in Crowdin. **Note:** Can't contain `\\ / : * ? \" < > |` symbols. `ZIP` files are not allowed.", | ||
| }, | ||
| branchId: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "branchId", | ||
| (c) => ({ | ||
| projectId: c.projectId, | ||
| }), | ||
| ], | ||
| }, | ||
| directoryId: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "directoryId", | ||
| (c) => ({ | ||
| projectId: c.projectId, | ||
| }), | ||
| ], | ||
| }, | ||
| title: { | ||
| type: "string", | ||
| label: "Title", | ||
| description: "Use to provide more details for translators. Title is available in UI only", | ||
| optional: true, | ||
| }, | ||
| context: { | ||
| type: "string", | ||
| label: "Context", | ||
| description: "Use to provide context about whole file", | ||
| optional: true, | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "File Type", | ||
| description: "The type of the file. **Note:** Use `docx` type to import each cell as a separate source string for XLSX file. Default is `auto`", | ||
| options: TYPE_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| parserVersion: { | ||
| type: "integer", | ||
| label: "Parser Version", | ||
| description: "Using latest parser version by default. **Note:** Must be used together with `type`.", | ||
| optional: true, | ||
| }, | ||
| attachLabelIds: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "attachLabelIds", | ||
| (c) => ({ | ||
| projectId: c.projectId, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| crowdin, | ||
| attachLabelIds, | ||
| projectId, | ||
| file, | ||
| ...data | ||
| } = this; | ||
|
|
||
| const fileBinary = fs.readFileSync(checkTmp(file)); | ||
| const crowdinFilename = file.startsWith("/tmp/") | ||
| ? file.slice(5) | ||
| : file; | ||
|
|
||
| const fileResponse = await crowdin.createStorage({ | ||
| data: Buffer.from(fileBinary, "binary"), | ||
| headers: { | ||
| "Crowdin-API-FileName": encodeURI(crowdinFilename), | ||
| "Content-Type": "application/octet-stream", | ||
| }, | ||
| }); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const response = await crowdin.uploadFileToProject({ | ||
| $, | ||
| projectId, | ||
| data: { | ||
| ...data, | ||
| storageId: fileResponse.data.id, | ||
| attachLabelIds: parseObject(attachLabelIds), | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully uploaded file: ${this.name}`); | ||
| return response; | ||
| }, | ||
| }; | ||
184 changes: 184 additions & 0 deletions
184
components/crowdin/actions/create-project/create-project.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import { | ||
| LANGUAGE_ACCESS_POLICY_OPTIONS, | ||
| TAGS_DETECTION_OPTIONS, | ||
| VISIBILITY_OPTIONS, | ||
| } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import crowdin from "../../crowdin.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "crowdin-create-project", | ||
| name: "Create Project", | ||
| description: "Creates a new project within Crowdin. [See the documentation](https://support.crowdin.com/developer/api/v2/#/projects-api/create-project)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| crowdin, | ||
| name: { | ||
| type: "string", | ||
| label: "Project Name", | ||
| description: "The name of the project to be created", | ||
| }, | ||
| sourceLanguageId: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "sourceLanguageId", | ||
| ], | ||
| }, | ||
| targetLanguageIds: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "sourceLanguageId", | ||
| ], | ||
| type: "string[]", | ||
| label: "Target Language IDs", | ||
| description: "Array of target language IDs", | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| identifier: { | ||
| type: "string", | ||
| label: "Identifier", | ||
| description: "A custom identifier for the project", | ||
| optional: true, | ||
| }, | ||
| visibility: { | ||
| type: "string", | ||
| label: "Visibility", | ||
| description: "Defines how users can join the project.", | ||
| options: VISIBILITY_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| languageAccessPolicy: { | ||
| type: "string", | ||
| label: "Language Access Policy", | ||
| description: "Defines access to project languages.", | ||
| optional: true, | ||
| options: LANGUAGE_ACCESS_POLICY_OPTIONS, | ||
| }, | ||
| cname: { | ||
| type: "string", | ||
| label: "Custom Domain Name", | ||
| description: "Custom domain name for the project.", | ||
| optional: true, | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Project Description", | ||
| description: "The description of the project.", | ||
| optional: true, | ||
| }, | ||
| tagsDetection: { | ||
| type: "string", | ||
| label: "Tags Detection", | ||
| description: "The type of the tags detection.", | ||
| options: TAGS_DETECTION_OPTIONS, | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| isMtAllowed: { | ||
| type: "boolean", | ||
| label: "Allow Machine Translation", | ||
| description: "Allows machine translations to be visible for translators. Default is **true**.", | ||
| optional: true, | ||
| }, | ||
| taskBasedAccessControl: { | ||
| type: "boolean", | ||
| label: "Task Based Access Control", | ||
| description: "Allow project members to work with tasks they're assigned to. Default is **false**.", | ||
| optional: true, | ||
| default: false, | ||
| }, | ||
| autoSubstitution: { | ||
| type: "boolean", | ||
| label: "Auto Substitution", | ||
| description: "Allows auto-substitution. Default is **true**.", | ||
| optional: true, | ||
| default: true, | ||
| }, | ||
| autoTranslateDialects: { | ||
| type: "boolean", | ||
| label: "Auto Translate Dialects", | ||
| description: "Automatically fill in regional dialects. Default is **false**.", | ||
| optional: true, | ||
| }, | ||
| publicDownloads: { | ||
| type: "boolean", | ||
| label: "Public Downloads", | ||
| description: "Allows translators to download source files. Default is **true**.", | ||
| optional: true, | ||
| }, | ||
| hiddenStringsProofreadersAccess: { | ||
| type: "boolean", | ||
| label: "Hidden Strings Proofreaders Access", | ||
| description: "Allows proofreaders to work with hidden strings. Default is **true**.", | ||
| optional: true, | ||
| default: true, | ||
| }, | ||
| useGlobalTm: { | ||
| type: "boolean", | ||
| label: "Use Global Translation Memory", | ||
| description: "If true, machine translations from connected MT engines will appear as suggestions. Default is **true**.", | ||
| optional: true, | ||
| }, | ||
| showTmSuggestionsDialects: { | ||
| type: "boolean", | ||
| label: "Show TM Suggestions for Dialects", | ||
| description: "Show primary language TM suggestions for dialects if there are no dialect-specific ones. Default is **true**.", | ||
| optional: true, | ||
| default: true, | ||
| }, | ||
| skipUntranslatedStrings: { | ||
| type: "boolean", | ||
| label: "Skip Untranslated Strings", | ||
| description: "Defines whether to skip untranslated strings.", | ||
| optional: true, | ||
| }, | ||
| exportApprovedOnly: { | ||
| type: "boolean", | ||
| label: "Export Approved Only", | ||
| description: "Defines whether to export only approved strings.", | ||
| optional: true, | ||
| }, | ||
| qaCheckIsActive: { | ||
| type: "boolean", | ||
| label: "QA Check Is Active", | ||
| description: "If true, QA checks are active. Default is **true**.", | ||
| optional: true, | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "Defines the project type. To create a file-based project, use 0.", | ||
| options: [ | ||
| "0", | ||
| "1", | ||
| ], | ||
| optional: true, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| try { | ||
| const { | ||
| crowdin, | ||
| type, | ||
| targetLanguageIds, | ||
| tagsDetection, | ||
| ...data | ||
| } = this; | ||
|
|
||
| const response = await crowdin.createProject({ | ||
| $, | ||
| data: { | ||
| ...data, | ||
| type: parseInt(type), | ||
| targetLanguageIds: parseObject(targetLanguageIds), | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| tagsDetection: parseInt(tagsDetection), | ||
| }, | ||
| }); | ||
| $.export("$summary", `Project created successfully with Id: ${response.data.id}`); | ||
| return response; | ||
| } catch ({ response }) { | ||
| throw new ConfigurationError(response.data.errors[0]?.error?.errors[0]?.message); | ||
| } | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
60 changes: 60 additions & 0 deletions
60
...s/crowdin/actions/translate-via-machine-translation/translate-via-machine-translation.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { LANGUAGE_R_PROVIDER_OPTIONS } from "../../common/constants.mjs"; | ||
| import crowdin from "../../crowdin.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "crowdin-translate-via-machine-translation", | ||
| name: "Translate via Machine Translation", | ||
| description: "Performs machine translation of the uploaded files. [See the documentation](https://support.crowdin.com/developer/api/v2/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| crowdin, | ||
| mtId: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "mtId", | ||
| ], | ||
| }, | ||
| targetLanguageId: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "sourceLanguageId", | ||
| ], | ||
| type: "string", | ||
| label: "Target Language ID", | ||
| description: "The language ID for the target translation language", | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| languageRecognitionProvider: { | ||
| type: "string", | ||
| label: "Language Recognition Provider", | ||
| description: "Select a provider for language recognition **Note:** Is required if the source language is not selected", | ||
| options: LANGUAGE_R_PROVIDER_OPTIONS, | ||
| }, | ||
| sourceLanguageId: { | ||
| propDefinition: [ | ||
| crowdin, | ||
| "sourceLanguageId", | ||
| ], | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| strings: { | ||
| type: "string[]", | ||
| label: "Strings", | ||
| description: "Array of strings to be translated. **Note:** You can translate up to 100 strings at a time.", | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.crowdin.performMachineTranslation({ | ||
| $, | ||
| mtId: this.mtId, | ||
| data: { | ||
| targetLanguageId: this.targetLanguageId, | ||
| strings: this.strings, | ||
| languageRecognitionProvider: this.languageRecognitionProvider, | ||
| sourceLanguageId: this.sourceLanguageId, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", "Successfully performed machine translation"); | ||
| return response; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.